diff options
Diffstat (limited to 'contrib/sort.py')
-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) |