summary refs log tree commit diff stats
path: root/ranger.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-10-08 19:46:41 +0200
committerhut <hut@lavabit.com>2010-10-08 19:46:41 +0200
commit8e0d73b53f164f949b55e268d9c76f0531b8c7d8 (patch)
treebf4f8ce8545f69d208b2b962ee2daa0c18c78947 /ranger.py
parentd56375f95f91b9670a2353ee8d8883eca5c35f1e (diff)
parent3668fb2c70524a4f3e988cc4760e319500f9a4fb (diff)
downloadranger-8e0d73b53f164f949b55e268d9c76f0531b8c7d8.tar.gz
Merge branch 'master' into preview
Conflicts:
	ranger/__init__.py
	ranger/core/helper.py
	ranger/gui/curses_shortcuts.py
Diffstat (limited to 'ranger.py')
-rwxr-xr-xranger.py43
1 files changed, 19 insertions, 24 deletions
diff --git a/ranger.py b/ranger.py
index 5652ba69..fbceab23 100755
--- a/ranger.py
+++ b/ranger.py
@@ -16,18 +16,17 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# ----------------------------------------------------------------------------
-#
-# An embedded shell script. It allows you to change the directory
-# after you exit ranger by starting it with: source ranger ranger
+
+# Embed a script which allows you to change the directory of the parent shell
+# after you exit ranger.  Run it with the command: source ranger ranger
 """":
 if [ $1 ]; then
+	$@ --fail-unless-cd &&
 	if [ -z "$XDG_CONFIG_HOME" ]; then
-		"$@" --fail-unless-cd && cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
+		cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
 	else
-		"$@" --fail-unless-cd && cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
-	fi
+		cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
+	fi && return 0
 else
 	echo "usage: source path/to/ranger.py path/to/ranger.py"
 fi
@@ -36,21 +35,17 @@ return 1
 
 import sys
 
-# Redefine the docstring, since the previous one was hijacked to
-# embed a shellscript.
+# When using the --clean option, not even bytecode should be written.
+# Need to find out if --clean is used as soon as possible.
+try:
+	argv = sys.argv[0:sys.argv.index('--')]
+except:
+	argv = sys.argv
+sys.dont_write_bytecode = '-c' in argv or '--clean' in argv
+
+# Set the actual docstring
 __doc__ = """Ranger - file browser for the unix terminal"""
 
-# Importing the main method may fail if the ranger directory
-# is neither in the same directory as this file, nor in one of
-# pythons global import paths.
-try:
-	from ranger.__main__ import main
-except ImportError:
-	if '-d' not in sys.argv and '--debug' not in sys.argv:
-		print("Can't import the main module.")
-		print("To run an uninstalled copy of ranger,")
-		print("launch ranger.py in the top directory.")
-	else:
-		raise
-else:
-	sys.exit(main())
+# Start ranger
+import ranger
+sys.exit(ranger.main())