From b1bf9a81033d7fbe413ee817c6da61ad567fbe3e Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Tue, 18 Oct 2022 17:02:35 -0300 Subject: 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 --- contrib/sort.py | 10 ++++++++-- 1 file 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 @@ # This file is part of Firejail project # Copyright (C) 2014-2022 Firejail Authors # License GPL v2 -""" +"""\ Sort the arguments of commands in profiles. Usage: ./sort.py [/path/to/profile ...] @@ -25,6 +25,7 @@ Examples: Exit Codes: 0: Success: No profiles needed fixing. 1: Error: One or more profiles could not be processed correctly. + 2: Error: Missing arguments. 101: Info: One or more profiles were fixed. """ @@ -94,8 +95,13 @@ def fix_profile(filename): def main(args): - exit_code = 0 + if len(args) < 1: + print(__doc__, file=stderr) + return 2 + print(f"sort.py: checking {len(args)} profile(s)...") + + exit_code = 0 for filename in args: try: if exit_code not in (1, 101): -- cgit v1.2.3-54-g00ecf