summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-11 23:00:27 +0100
committerhut <hut@lavabit.com>2010-01-11 23:00:27 +0100
commit5e4496993a297d0c7591084bd54f3df66d4ffe66 (patch)
tree9867a16a7a06dfd09281754a8aa58629621b6095
parent6369406e64208b69a8847aef3b196640bdfc7190 (diff)
downloadranger-5e4496993a297d0c7591084bd54f3df66d4ffe66.tar.gz
fixed #31, cd-after-exit works even after pressing ^C
-rw-r--r--TODO2
-rwxr-xr-xranger.py13
2 files changed, 13 insertions, 2 deletions
diff --git a/TODO b/TODO
index 52812959..8f1c5a42 100644
--- a/TODO
+++ b/TODO
@@ -37,7 +37,7 @@ Bugs
    (X) #23  10/01/04  stop dir loading with ^C -> wont load anymore
    (X) #25  10/01/06  directories sometimes dont reload correctly
    (X) #26  10/01/06  :delete on symlinks of directories fails
-   ( ) #31  10/01/06  ^C breaks cd-after-exit by stopping sourced shell script
+   (X) #31  10/01/06  ^C breaks cd-after-exit by stopping sourced shell script
 
 
 Ideas
diff --git a/ranger.py b/ranger.py
index 6915457f..d11b49d9 100755
--- a/ranger.py
+++ b/ranger.py
@@ -24,9 +24,20 @@
 #     source /path/ranger /path/ranger
 """":
 if [ $1 ]; then
+	trap "kill -2 %+" INT
+
 	RANGER="$1"
 	shift
-	cd "`$RANGER --cd-after-exit \"$@\" 3>&1 1>&2 2>&3 3>&-`"
+
+	exec 3< <($RANGER --cd-after-exit $@ 3>&1 1>&2 2>&3 3>&-)
+	read NEWDIR <&3
+	exec 3<&-
+
+	cd $NEWDIR
+
+	trap - INT
+	unset RANGER
+	unset NEWDIR
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"
 fi