summaryrefslogtreecommitdiffstats
path: root/bin/portageq
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-08-10 23:47:38 -0700
committerZac Medico <zmedico@gentoo.org>2010-08-10 23:47:38 -0700
commita0f36346655b51f719ee2d63e66974a4e1595011 (patch)
tree009a0a46283a4404e9bfab00ce0ebdf47826c81c /bin/portageq
parentf543e87f9f41a55d2acffbf57842fc4e409090ac (diff)
downloadportage-a0f36346655b51f719ee2d63e66974a4e1595011.tar.gz
portage-a0f36346655b51f719ee2d63e66974a4e1595011.tar.bz2
portage-a0f36346655b51f719ee2d63e66974a4e1595011.zip
Make sure portageq doesn't interpret anything that happens to be
in globals() (such as imported modules) as a valid command.
Diffstat (limited to 'bin/portageq')
-rwxr-xr-xbin/portageq11
1 files changed, 6 insertions, 5 deletions
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]