samba-tool: Correctly handle sys.exit() called from subcommand
authorAmitay Isaacs <amitay@gmail.com>
Fri, 9 Sep 2011 03:22:27 +0000 (13:22 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 9 Sep 2011 05:24:04 +0000 (15:24 +1000)
Catch SystemExit exception if any subcommand calls sys.exit()
and return with failure (-1).

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/bin/samba-tool

index 2e920410768edd8f30c751fece02f931d332e6b7..c191865152157b9aeae83de3332a7dd11a43f441 100755 (executable)
@@ -77,6 +77,8 @@ if __name__ == '__main__':
 
     try:
         retval = cmd._run("samba-tool", subcommand, *args)
-        sys.exit(retval)
+    except SystemExit, e:
+       retval = -1
     except Exception, e:
         cmd.show_command_error(e)
+    sys.exit(retval)