From: Douglas Bagnall Date: Wed, 15 Jan 2025 02:32:18 +0000 (+1300) Subject: samba-tool: --version shortcircuits option evaluation X-Git-Tag: tevent-0.17.0~854 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a61e192f25c61fc4f464585f6d4153c26aece352;p=thirdparty%2Fsamba.git samba-tool: --version shortcircuits option evaluation This means in bin/samba-tool spn -h -V the -V takes precedence over the -h, as with the 'net' tool. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15770 Signed-off-by: Douglas Bagnall Reviewed-by: Jennifer Sutton --- diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index 3f9cb3276eb..9aa4664418a 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -446,7 +446,10 @@ class SuperCommand(Command): sub = self.subcommands[a] return sub._resolve(sub_path, *sub_args, outf=outf, errf=errf) - elif a in ['--help', 'help', None, '-h', '-V', '--version']: + if a in ['-V', '--version']: + return (self, [a]) + + if a in ['--help', 'help', None, '-h']: # we pass these to the leaf node. if a == 'help': a = '--help' @@ -457,7 +460,7 @@ class SuperCommand(Command): print("%s: no such subcommand: %s\n" % (path, a), file=self.outf) return (self, []) - # We didn't find a subcommand, but maybe we found e.g. --version + # We didn't find a subcommand, but maybe we found e.g. --help if not deferred_args: print("%s: missing subcommand\n" % (path), file=self.outf) return (self, deferred_args) diff --git a/selftest/knownfail.d/samba-tool--version b/selftest/knownfail.d/samba-tool--version index 858cc19b848..f02938dec8f 100644 --- a/selftest/knownfail.d/samba-tool--version +++ b/selftest/knownfail.d/samba-tool--version @@ -1,4 +1,2 @@ ^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_help_version\(none\) -^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version_beats_help\(none\) ^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_help_version\(fileserver\) -^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version_beats_help\(fileserver\)