From: Bruno Haible <bruno@clisp.org>
Date: Sun, 31 Jul 2022 16:48:25 +0000 (+0200)
Subject: gnulib-tool.py: Improve compliance with GNU standards.
X-Git-Tag: v1.0~2202
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=45802545353c971265bde432755647a3bbf0a973;p=gnulib.git

gnulib-tool.py: Improve compliance with GNU standards.

* gnulib-tool.py (main): Handle --help and --version before testing for
conflicting modes.
---

diff --git a/ChangeLog b/ChangeLog
index af97fc0ee6..bdbdf1516f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2022-07-31  Bruno Haible  <bruno@clisp.org>
 
+	gnulib-tool.py: Improve compliance with GNU standards.
+	* gnulib-tool.py (main): Handle --help and --version before testing for
+	conflicting modes.
+
 	gnulib-tool.py: Emit error message when conflicting modes are specified.
 	* gnulib-tool.py (main): Fix test of conflicting modes. (Some options
 	produce a value of [], and as a condition, [] evaluates to False.)
diff --git a/gnulib-tool.py b/gnulib-tool.py
index b16becb1d2..a6d4f6fa75 100755
--- a/gnulib-tool.py
+++ b/gnulib-tool.py
@@ -340,6 +340,17 @@ def main():
     # Parse the given arguments.
     cmdargs = parser.parse_args()
 
+    # Handle --help and --version, ignoring all other options.
+    if cmdargs.help != None:
+        print(info.usage())
+        sys.exit(0)
+    if cmdargs.version != None:
+        message = '''gnulib-tool (%s %s)%s\n%s\n%s\n\nWritten by %s.''' % \
+            (info.package(), info.date(), info.version(), info.copyright(),
+             info.license(), info.authors())
+        print(message)
+        sys.exit(0)
+
     # Determine when user tries to combine modes.
     args = [
         cmdargs.mode_list,
@@ -374,15 +385,6 @@ def main():
         sys.exit(1)
 
     # Determine selected mode.
-    if cmdargs.help != None:
-        print(info.usage())
-        sys.exit(0)
-    if cmdargs.version != None:
-        message = '''gnulib-tool (%s %s)%s\n%s\n%s\n\nWritten by %s.''' % \
-            (info.package(), info.date(), info.version(), info.copyright(),
-             info.license(), info.authors())
-        print(message)
-        sys.exit(0)
     if cmdargs.mode_list != None:
         mode = 'list'
     if cmdargs.mode_import != None: