From: Zac Medico Date: Wed, 11 Aug 2010 06:47:38 +0000 (-0700) Subject: Make sure portageq doesn't interpret anything that happens to be X-Git-Tag: v2.2_rc68~317 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a0f36346655b51f719ee2d63e66974a4e1595011;p=portage.git Make sure portageq doesn't interpret anything that happens to be in globals() (such as imported modules) as a valid command. --- diff --git a/bin/portageq b/bin/portageq index 34a538599..ce72df046 100755 --- a/bin/portageq +++ b/bin/portageq @@ -571,6 +571,11 @@ list_preserved_libs.uses_root = True # DO NOT CHANGE CODE BEYOND THIS POINT - IT'S NOT NEEDED! # +non_commands = frozenset(['eval_atom_use', 'exithandler', 'main', + 'usage', 'writemsg', 'writemsg_stdout']) +commands = sorted(k for k, v in globals().items() \ + if type(v) is types.FunctionType and k not in non_commands) + def usage(argv): print(">>> Portage information query tool") print(">>> %s" % portage.VERSION) @@ -582,10 +587,6 @@ def usage(argv): # Show our commands -- we do this by scanning the functions in this # file, and formatting each functions documentation. # - non_commands = frozenset(['eval_atom_use', 'exithandler', 'main', - 'usage', 'writemsg', 'writemsg_stdout']) - commands = sorted(k for k, v in globals().items() \ - if type(v) is types.FunctionType and k not in non_commands) for name in commands: # Drop non-functions @@ -620,7 +621,7 @@ def main(): cmd = sys.argv[1] function = globals().get(cmd) - if function is None: + if function is None or cmd not in commands: usage(sys.argv) sys.exit(os.EX_USAGE) function = globals()[cmd]