core.runner: show stderr when using 'p' flag (#884)
[ranger.git] / ranger.py
blob3c4b0f0181804df3923130da1b98100d419b8168
1 #!/usr/bin/python -O
2 # This file is part of ranger, the console file manager. (coding: utf-8)
3 # License: GNU GPL version 3, see the file "AUTHORS" for details.
5 # =====================
6 # This embedded bash script can be executed by sourcing this file.
7 # It will cd to ranger's last location after you exit it.
8 # The first argument specifies the command to run ranger, the
9 # default is simply "ranger". (Not this file itself!)
10 # The other arguments are passed to ranger.
11 """":
12 tempfile="$(mktemp -t tmp.XXXXXX)"
13 ranger="${1:-ranger}"
14 test -z "$1" || shift
15 "$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
16 returnvalue=$?
17 test -f "$tempfile" &&
18 if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
19 cd "$(cat "$tempfile")"
21 rm -f -- "$tempfile"
22 return $returnvalue
23 """
25 from __future__ import (absolute_import, division, print_function)
27 import sys
29 # Need to find out whether or not the flag --clean was used ASAP,
30 # because --clean is supposed to disable bytecode compilation
31 ARGV = sys.argv[1:sys.argv.index('--')] if '--' in sys.argv else sys.argv[1:]
32 sys.dont_write_bytecode = '-c' in ARGV or '--clean' in ARGV
34 # Start ranger
35 import ranger # NOQA pylint: disable=import-self,wrong-import-position
36 sys.exit(ranger.main()) # pylint: disable=no-member