diff options
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) |