summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-04 02:24:52 +0200
committerhut <hut@lavabit.com>2011-10-04 02:24:52 +0200
commit06848dc3f83e940cf26342a5b6dfeb31c88e1f06 (patch)
tree04e9cda25aae00095a4e35ac951513e23e143cb5
parentd40d1cf901a914430190068e6d8f56e0eb29107d (diff)
downloadranger-06848dc3f83e940cf26342a5b6dfeb31c88e1f06.tar.gz
ranger.py: made the argument optional in embedded bash script
-rwxr-xr-xranger.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/ranger.py b/ranger.py
index 44fc298f..2a9c68a0 100755
--- a/ranger.py
+++ b/ranger.py
@@ -15,23 +15,24 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Embed a script which allows you to change the directory of the parent shell
-# after you exit ranger.  Run it with the command: source ranger ranger
+# =====================
+# This embedded bash script can be executed by sourcing this file.
+# It will cd to ranger's last location after you exit it.
+# The first argument specifies the command to run ranger, the
+# default is simply "ranger". (Not this file itself!)
+# The other arguments are passed to ranger.
 """":
-if [ ! -z "$1" ]; then
-	tempfile='/tmp/chosendir'
-	ranger="$1"
-	shift
-	"$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
-	test -f "$tempfile" &&
-	if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
-		cd "$(cat "$tempfile")"
-		rm -f -- "$tempfile"
-	fi && return 0
-else
-	echo "usage: source path/to/ranger.py path/to/ranger.py"
+tempfile='/tmp/chosendir'
+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")"
+	rm -f -- "$tempfile"
 fi
-return 1
+return $returnvalue
 """
 
 import sys
nisanti/profani-tty/blame/src/ui/buffer.h?id=30c1cdd3185cbbc59f79ce16305b1c099ee4044f'>^
8c027a56 ^
2786b7cb ^
ed4391ec ^
2786b7cb ^

10142444 ^
6a9e1930 ^

1e6b7094 ^
6a9e1930 ^
1e6b7094 ^

5576b88a ^
559ff72c ^
1e6b7094 ^
b125fa0f ^
559ff72c ^
10142444 ^
1e6b7094 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69