aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2024-05-13 20:01:25 -0300
committerLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2024-05-13 20:22:30 -0300
commita6d2119ee67178773dddf79a3275ae3b17becb69 (patch)
treef9c4dc882372ed2b0b362ec3089304cfa61e9522
parentbuild: sort.py: use -i by default and add -n (diff)
downloadfirejail-a6d2119ee67178773dddf79a3275ae3b17becb69.tar.gz
firejail-a6d2119ee67178773dddf79a3275ae3b17becb69.tar.zst
firejail-a6d2119ee67178773dddf79a3275ae3b17becb69.zip
build: sort.py: support "--" and fail on unknown option
Support "--" to end options and fail if an unknown option is given.
-rwxr-xr-xcontrib/sort.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/sort.py b/contrib/sort.py
index fa7adb8cb..d6e601ff8 100755
--- a/contrib/sort.py
+++ b/contrib/sort.py
@@ -11,7 +11,7 @@ from sys import argv, exit as sys_exit, stderr
11__doc__ = f"""\ 11__doc__ = f"""\
12Sort the arguments of commands in profiles. 12Sort the arguments of commands in profiles.
13 13
14Usage: {path.basename(argv[0])} [-i] [-n] [/path/to/profile ...] 14Usage: {path.basename(argv[0])} [-i] [-n] [--] [/path/to/profile ...]
15 15
16The following commands are supported: 16The following commands are supported:
17 17
@@ -23,6 +23,7 @@ Note that this is only applicable to commands that support multiple arguments.
23Options: 23Options:
24 -i Edit the profile file(s) in-place (this is the default). 24 -i Edit the profile file(s) in-place (this is the default).
25 -n Do not edit the profile file(s) in-place. 25 -n Do not edit the profile file(s) in-place.
26 -- End of options
26 27
27Examples: 28Examples:
28 $ {argv[0]} MyAwesomeProfile.profile 29 $ {argv[0]} MyAwesomeProfile.profile
@@ -110,6 +111,12 @@ def main(args):
110 elif args[0] == "-n": 111 elif args[0] == "-n":
111 overwrite = False 112 overwrite = False
112 args.pop(0) 113 args.pop(0)
114 elif args[0] == "--":
115 args.pop(0)
116 break
117 elif args[0][0] == "-":
118 print(f"[ Error ] Unknown option: {args[0]}", file=stderr)
119 return 2
113 else: 120 else:
114 break 121 break
115 122