diff options
| author | hut <hut@lavabit.com> | 2010-04-26 13:32:40 +0200 |
|---|---|---|
| committer | hut <hut@lavabit.com> | 2010-04-26 20:57:40 +0200 |
| commit | 83868c7aa8ca35d9d0c1606dd62b44e97bd7e356 (patch) | |
| tree | 60ba5092dfa274632f5c6da3d45b758bcb6386ce | |
| parent | f3bc52e556867d00fa1ba51f9dc93a2cde75b15b (diff) | |
| download | ranger-83868c7aa8ca35d9d0c1606dd62b44e97bd7e356.tar.gz | |
Fixed bug #65 by adding flag "--fail-if-run"
| -rw-r--r-- | README | 2 | ||||
| -rw-r--r-- | TODO | 2 | ||||
| -rw-r--r-- | doc/ranger.1 | 6 | ||||
| -rwxr-xr-x | ranger.py | 2 | ||||
| -rw-r--r-- | ranger/__main__.py | 5 |
5 files changed, 12 insertions, 5 deletions
@@ -147,7 +147,7 @@ Tips Change the directory of your parent shell when you exit ranger: ranger() { - command ranger $@ && + command ranger --fail-if-run $@ && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)" } @@ -74,7 +74,7 @@ Bugs (X) #54 10/01/23 max_dirsize_for_autopreview not working ( ) #60 10/02/05 utf support improvable (X) #62 10/02/15 curs_set can raise an exception - ( ) #65 10/02/16 "source ranger ranger some/file.txt" shouldn't cd after exit + (X) #65 10/02/16 "source ranger ranger some/file.txt" shouldn't cd after exit (X) #67 10/03/08 terminal title in tty (X) #69 10/03/11 tab-completion breaks with Apps subclass (X) #73 10/03/21 when clicking on the first column, it goes 1x down diff --git a/doc/ranger.1 b/doc/ranger.1 index 68353dd9..b197d774 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -33,6 +33,10 @@ Activate the clean mode: Ranger will not access or create any configuration files nor will it leave any traces on your system. This is useful when your configuration is broken, when you want to avoid clutter, etc. .TP +--fail-if-run +Return the exit code 1 if ranger is used to run a file, for example with +`ranger --fail-if-run filename`. This can be useful for scripts. +.TP -r \fIdir\fR, --confdir=\fIdir\fR Define a different configuration directory. The default is $HOME/.ranger. .TP @@ -172,7 +176,7 @@ of your parent shell after exiting ranger: .nf ranger() { - command ranger $@ && + command ranger --fail-if-run $@ && cd "$(grep \\^\\' ~/.ranger/bookmarks | cut -b3-)" } .\"----------------------------------------- @@ -23,7 +23,7 @@ # after you exit ranger by starting it with: source ranger ranger """": if [ $1 ]; then - $@ && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)" + $@ --fail-if-run && cd "$(grep \^\' ~/.ranger/bookmarks | cut -b3-)" else echo "usage: source path/to/ranger.py path/to/ranger.py" fi diff --git a/ranger/__main__.py b/ranger/__main__.py index 0814565f..8bb0bfa1 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -45,6 +45,9 @@ def parse_arguments(): help="activate debug mode") parser.add_option('-c', '--clean', action='store_true', help="don't touch/require any config files. ") + parser.add_option('--fail-if-run', action='store_true', + help="experimental: return the exit code 1 if ranger is" \ + "used to run a file (with `ranger filename`)") parser.add_option('-r', '--confdir', type='string', metavar='dir', default=DEFAULT_CONFDIR, help="the configuration directory. (%default)") @@ -178,7 +181,7 @@ def main(): runner = Runner(logfunc=print_function) load_apps(runner, ranger.arg.clean) runner(files=[File(target)], mode=arg.mode, flags=arg.flags) - sys.exit(0) + sys.exit(1 if arg.fail_if_run else 0) else: path = target else: |