diff options
author | 2024-05-20 03:40:38 +0000 | |
---|---|---|
committer | 2024-05-20 03:40:38 +0000 | |
commit | 83469a3b7ed9bd2893ed81a1cab05558ff9b6bd5 (patch) | |
tree | cf61323f5ce3aa405bce17201e9358df193ddf6e /contrib | |
parent | build(deps): bump github/codeql-action from 3.25.4 to 3.25.5 (diff) | |
parent | build: sort.py: support "--" and fail on unknown option (diff) | |
download | firejail-83469a3b7ed9bd2893ed81a1cab05558ff9b6bd5.tar.gz firejail-83469a3b7ed9bd2893ed81a1cab05558ff9b6bd5.tar.zst firejail-83469a3b7ed9bd2893ed81a1cab05558ff9b6bd5.zip |
Merge pull request #6339 from kmk3/build-sort-py-n
build: sort.py: use -i by default and add -n
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/sort.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/contrib/sort.py b/contrib/sort.py index b65d87ab7..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] [/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 | ||
@@ -21,13 +21,15 @@ The following commands are supported: | |||
21 | Note that this is only applicable to commands that support multiple arguments. | 21 | Note that this is only applicable to commands that support multiple arguments. |
22 | 22 | ||
23 | Options: | 23 | Options: |
24 | -i Edit the profile file(s) in-place. | 24 | -i Edit the profile file(s) in-place (this is the default). |
25 | -n Do not edit the profile file(s) in-place. | ||
26 | -- End of options | ||
25 | 27 | ||
26 | Examples: | 28 | Examples: |
27 | $ {argv[0]} -i MyAwesomeProfile.profile | 29 | $ {argv[0]} MyAwesomeProfile.profile |
28 | $ {argv[0]} -i new_profile.profile second_new_profile.profile | 30 | $ {argv[0]} new_profile.profile second_new_profile.profile |
29 | $ {argv[0]} -i ~/.config/firejail/*.{{profile,inc,local}} | 31 | $ {argv[0]} ~/.config/firejail/*.{{profile,inc,local}} |
30 | $ sudo {argv[0]} -i /etc/firejail/*.{{profile,inc,local}} | 32 | $ sudo {argv[0]} /etc/firejail/*.{{profile,inc,local}} |
31 | 33 | ||
32 | Exit Codes: | 34 | Exit Codes: |
33 | 0: Success: No profiles needed fixing. | 35 | 0: Success: No profiles needed fixing. |
@@ -101,10 +103,22 @@ def check_profile(filename, overwrite): | |||
101 | 103 | ||
102 | 104 | ||
103 | def main(args): | 105 | def main(args): |
104 | overwrite = False | 106 | overwrite = True |
105 | if len(args) > 0 and args[0] == "-i": | 107 | while len(args) > 0: |
106 | overwrite = True | 108 | if args[0] == "-i": |
107 | args.pop(0) | 109 | overwrite = True |
110 | args.pop(0) | ||
111 | elif args[0] == "-n": | ||
112 | overwrite = False | ||
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 | ||
120 | else: | ||
121 | break | ||
108 | 122 | ||
109 | if len(args) < 1: | 123 | if len(args) < 1: |
110 | print(__doc__, file=stderr) | 124 | print(__doc__, file=stderr) |