From 5e4496993a297d0c7591084bd54f3df66d4ffe66 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 11 Jan 2010 23:00:27 +0100 Subject: fixed #31, cd-after-exit works even after pressing ^C --- TODO | 2 +- ranger.py | 13 ++++++++++++- 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 -- cgit 1.4.1-2-gfad0