From: Zac Medico Date: Sun, 21 Oct 2007 06:07:49 +0000 (-0000) Subject: Bug #196537 - Make portageq check that the parameter X-Git-Tag: v2.2_pre1~576 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c3865d5ac3f20b083a4d10d8818da26595768e13;p=portage.git Bug #196537 - Make portageq check that the parameter is an existing directory and exit gracefully if not. svn path=/main/trunk/; revision=8195 --- diff --git a/bin/portageq b/bin/portageq index f3177cb50..2fd1a1852 100755 --- a/bin/portageq +++ b/bin/portageq @@ -422,11 +422,20 @@ def main(): sys.exit(os.EX_USAGE) cmd = sys.argv[1] + function = globals().get(cmd) + if function is None: + usage(sys.argv) + sys.exit(os.EX_USAGE) + function = globals()[cmd] + uses_root = getattr(function, "uses_root", False) and len(sys.argv) > 2 + if uses_root: + if not os.path.isdir(sys.argv[2]): + sys.stderr.write("Not a directory: '%s'\n" % sys.argv[2]) + sys.stderr.write("Run portageq with --help for info\n") + sys.stderr.flush() + sys.exit(os.EX_USAGE) + os.environ["ROOT"] = sys.argv[2] try: - function = globals()[cmd] - uses_root = (getattr(function, "uses_root", False) and len(sys.argv) > 2) - if uses_root: - os.environ["ROOT"] = sys.argv[2] global portage try: import portage @@ -439,9 +448,6 @@ def main(): retval = function(sys.argv[2:]) if retval: sys.exit(retval) - except KeyError: - usage(sys.argv) - sys.exit(os.EX_USAGE) except portage.exception.PermissionDenied, e: sys.stderr.write("Permission denied: '%s'\n" % str(e)) sys.exit(e.errno)