diff options
author | 2024-05-13 20:01:25 -0300 | |
---|---|---|
committer | 2024-05-13 20:22:30 -0300 | |
commit | a6d2119ee67178773dddf79a3275ae3b17becb69 (patch) | |
tree | f9c4dc882372ed2b0b362ec3089304cfa61e9522 /contrib/sort.py | |
parent | build: sort.py: use -i by default and add -n (diff) | |
download | firejail-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.
Diffstat (limited to 'contrib/sort.py')
-rwxr-xr-x | contrib/sort.py | 9 |
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"""\ |
12 | Sort the arguments of commands in profiles. | 12 | Sort the arguments of commands in profiles. |
13 | 13 | ||
14 | Usage: {path.basename(argv[0])} [-i] [-n] [/path/to/profile ...] | 14 | Usage: {path.basename(argv[0])} [-i] [-n] [--] [/path/to/profile ...] |
15 | 15 | ||
16 | The following commands are supported: | 16 | The following commands are supported: |
17 | 17 | ||
@@ -23,6 +23,7 @@ Note that this is only applicable to commands that support multiple arguments. | |||
23 | Options: | 23 | Options: |
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 | ||
27 | Examples: | 28 | Examples: |
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 | ||