diff options
author | hut <hut@lavabit.com> | 2009-07-24 18:13:27 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-24 18:13:27 +0200 |
commit | 91b0fb9fd9c2e2199c25a988deb97c2d26093366 (patch) | |
tree | 2ca85b85af0fc3c953f7771f3219ae924313707e | |
parent | 48d405d7fd8b92bb2e0749d01f0fe516fe7ce19d (diff) | |
download | ranger-91b0fb9fd9c2e2199c25a988deb97c2d26093366.tar.gz |
use third file descriptor again. swapping STDERR/STDOUT fails
-rw-r--r-- | code/fm.rb | 6 | ||||
-rwxr-xr-x | ranger | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/code/fm.rb b/code/fm.rb index bda90196..3f1f442f 100644 --- a/code/fm.rb +++ b/code/fm.rb @@ -77,8 +77,10 @@ module Fm $VERBOSE = old_verbose_level end - def dump_pwd_to_stderr() - STDERR.puts( Fm.pwd.path ) + def dump_pwd_to_3() + three = File.open(3, 'a') + three.puts( Fm.pwd.path ) + three.close end def boot_up(pwd=nil) diff --git a/ranger b/ranger index d2f70578..ee0c7b41 100755 --- a/ranger +++ b/ranger @@ -17,7 +17,7 @@ fi ## check whether the command $CMD exists. if [ $(command -v $CMD) ]; then - cd "`$CMD $@ 3>&2 2>&1 1>&3-`" + cd "`$CMD $@ 3>&1 1>&2`" else echo "error: please use this command, with two times the exact same path:" echo "source '/path/to/ranger' '/path/to/ranger'" @@ -35,8 +35,9 @@ end # cd `program` # # 2. Because STDOUT is sent to cd and STDERR is still printed, -# we swap STDOUT and STDERR with "3>&2 2>&1 1>&3-". -# When ranger exists, it will print the last dir to STDOUT. +# we need to redirect the normal output to STDERR and, only +# when ranger exists, print the last dir to STDOUT. +# that's done with "3>&1 1>&2" # # 3. If you source this file, by typing "source ranger", # all the work is done for you automagically. This file is @@ -218,7 +219,7 @@ ensure CLI.stop_mouse Fm.dump - Fm.dump_pwd_to_stderr if Option.cd rescue nil + Fm.dump_pwd_to_3 if Option.cd rescue nil # Kill all other threads for thr in Thread.list |