diff options
author | Kelvin M. Klann <kmk3.code@protonmail.com> | 2024-05-13 19:55:30 -0300 |
---|---|---|
committer | Kelvin M. Klann <kmk3.code@protonmail.com> | 2024-05-13 20:15:45 -0300 |
commit | b177ec0552e6180e9ff7111ef0793f783791c4a2 (patch) | |
tree | 28ad39c6803d22bbe105d23c59e74a0d9b2d26c0 /contrib/sort.py | |
parent | build(deps): bump github/codeql-action from 3.25.3 to 3.25.4 (diff) | |
download | firejail-b177ec0552e6180e9ff7111ef0793f783791c4a2.tar.gz firejail-b177ec0552e6180e9ff7111ef0793f783791c4a2.tar.zst firejail-b177ec0552e6180e9ff7111ef0793f783791c4a2.zip |
build: sort.py: use -i by default and add -n
Overwrite in-place by default (`-i`) and add `-n` to override it.
This restores the previous default behavior (from 0.9.72), for the sake
of being consistent with all previous versions and because it's more
likely to be the desired behavior in most cases.
This amends commit aa08aa132 ("build: sort.py: add and require -i to
edit in-place (#6290)", 2024-03-25).
Diffstat (limited to 'contrib/sort.py')
-rwxr-xr-x | contrib/sort.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/contrib/sort.py b/contrib/sort.py index b65d87ab7..fa7adb8cb 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,14 @@ 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. | ||
25 | 26 | ||
26 | Examples: | 27 | Examples: |
27 | $ {argv[0]} -i MyAwesomeProfile.profile | 28 | $ {argv[0]} MyAwesomeProfile.profile |
28 | $ {argv[0]} -i new_profile.profile second_new_profile.profile | 29 | $ {argv[0]} new_profile.profile second_new_profile.profile |
29 | $ {argv[0]} -i ~/.config/firejail/*.{{profile,inc,local}} | 30 | $ {argv[0]} ~/.config/firejail/*.{{profile,inc,local}} |
30 | $ sudo {argv[0]} -i /etc/firejail/*.{{profile,inc,local}} | 31 | $ sudo {argv[0]} /etc/firejail/*.{{profile,inc,local}} |
31 | 32 | ||
32 | Exit Codes: | 33 | Exit Codes: |
33 | 0: Success: No profiles needed fixing. | 34 | 0: Success: No profiles needed fixing. |
@@ -101,10 +102,16 @@ def check_profile(filename, overwrite): | |||
101 | 102 | ||
102 | 103 | ||
103 | def main(args): | 104 | def main(args): |
104 | overwrite = False | 105 | overwrite = True |
105 | if len(args) > 0 and args[0] == "-i": | 106 | while len(args) > 0: |
106 | overwrite = True | 107 | if args[0] == "-i": |
107 | args.pop(0) | 108 | overwrite = True |
109 | args.pop(0) | ||
110 | elif args[0] == "-n": | ||
111 | overwrite = False | ||
112 | args.pop(0) | ||
113 | else: | ||
114 | break | ||
108 | 115 | ||
109 | if len(args) < 1: | 116 | if len(args) < 1: |
110 | print(__doc__, file=stderr) | 117 | print(__doc__, file=stderr) |