about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/ranger.py b/ranger.py
index 3c4b0f01..57e2b082 100755
--- a/ranger.py
+++ b/ranger.py
@@ -9,17 +9,18 @@
 # default is simply "ranger". (Not this file itself!)
 # The other arguments are passed to ranger.
 """":
-tempfile="$(mktemp -t tmp.XXXXXX)"
+temp_file="$(mktemp)"
 ranger="${1:-ranger}"
-test -z "$1" || shift
-"$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
-returnvalue=$?
-test -f "$tempfile" &&
-if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
-    cd "$(cat "$tempfile")"
+if [ -n "$1" ]; then
+  shift
 fi
-rm -f -- "$tempfile"
-return $returnvalue
+"$ranger" --choosedir="$temp_file" -- "${@:-$PWD}"
+return_value="$?"
+if chosen_dir="$(cat "$temp_file")" && [ -n "$chosen_dir" ]; then
+    cd -- "$chosen_dir"
+fi
+rm -f -- "$temp_file"
+return "$return_value"
 """
 
 from __future__ import (absolute_import, division, print_function)