aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2022-10-18 17:02:35 -0300
committerLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2022-10-21 22:03:21 -0300
commitb1bf9a81033d7fbe413ee817c6da61ad567fbe3e (patch)
tree3b16bddee0e5e05e8a89387204d5cf63939fb361 /contrib
parentsort.py: print more standard error messages (diff)
downloadfirejail-b1bf9a81033d7fbe413ee817c6da61ad567fbe3e.tar.gz
firejail-b1bf9a81033d7fbe413ee817c6da61ad567fbe3e.tar.zst
firejail-b1bf9a81033d7fbe413ee817c6da61ad567fbe3e.zip
sort.py: print usage if there are no arguments
And return a specific exit code, as suggested by @rusty-snake[1]. Escape the first line in the docstring to avoid printing a blank line as the first line of the output. [1] https://github.com/netblue30/firejail/pull/5429#discussion_r999637842
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/sort.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/sort.py b/contrib/sort.py
index 5cd4045f0..388a29710 100755
--- a/contrib/sort.py
+++ b/contrib/sort.py
@@ -2,7 +2,7 @@
2# This file is part of Firejail project 2# This file is part of Firejail project
3# Copyright (C) 2014-2022 Firejail Authors 3# Copyright (C) 2014-2022 Firejail Authors
4# License GPL v2 4# License GPL v2
5""" 5"""\
6Sort the arguments of commands in profiles. 6Sort the arguments of commands in profiles.
7 7
8Usage: ./sort.py [/path/to/profile ...] 8Usage: ./sort.py [/path/to/profile ...]
@@ -25,6 +25,7 @@ Examples:
25Exit Codes: 25Exit Codes:
26 0: Success: No profiles needed fixing. 26 0: Success: No profiles needed fixing.
27 1: Error: One or more profiles could not be processed correctly. 27 1: Error: One or more profiles could not be processed correctly.
28 2: Error: Missing arguments.
28 101: Info: One or more profiles were fixed. 29 101: Info: One or more profiles were fixed.
29""" 30"""
30 31
@@ -94,8 +95,13 @@ def fix_profile(filename):
94 95
95 96
96def main(args): 97def main(args):
97 exit_code = 0 98 if len(args) < 1:
99 print(__doc__, file=stderr)
100 return 2
101
98 print(f"sort.py: checking {len(args)} profile(s)...") 102 print(f"sort.py: checking {len(args)} profile(s)...")
103
104 exit_code = 0
99 for filename in args: 105 for filename in args:
100 try: 106 try:
101 if exit_code not in (1, 101): 107 if exit_code not in (1, 101):