From 6a658676ce751b5b4db106556381cecd44be0193 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 12 Aug 2012 17:07:55 +0100 Subject: [PATCH] "0install add": show hint about adding the directory to $PATH This is the same logic we already had in 0alias. --- zeroinstall/apps.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zeroinstall/apps.py b/zeroinstall/apps.py index f500e13..6e32bf7 100644 --- a/zeroinstall/apps.py +++ b/zeroinstall/apps.py @@ -20,6 +20,13 @@ def validate_name(name): if valid_name.match(name): return raise SafeException("Invalid application name '{name}'".format(name = name)) +def _export(name, value): + """Try to guess the command to set an environment variable.""" + shell = os.environ.get('SHELL', '?') + if 'csh' in shell: + return "setenv %s %s" % (name, value) + return "export %s=%s" % (name, value) + def find_bin_dir(paths = None): """Find the first writable path in the list (default $PATH), skipping /bin, /sbin and everything under /usr except /usr/local/bin""" @@ -38,7 +45,8 @@ def find_bin_dir(paths = None): else: break else: - return None + path = os.path.expanduser('~/bin/') + warn('%s is not in $PATH. Add it with:\n%s' % (path, _export('PATH', path + ':$PATH'))) return path -- 2.11.4.GIT