From be39f4d682dce325b36f2a7344662cc181bba312 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sun, 19 Feb 2023 19:50:01 +0530 Subject: fix: getopts, properly handle optargs --- soibox | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/soibox b/soibox index c2ddb83..ada7fd9 100755 --- a/soibox +++ b/soibox @@ -16,13 +16,13 @@ usage() --version Echo the ${0##*/} version Options: -i Ignore global config - -l 0-3 Loglevel, 1 being nothing, 2 being errors, and 3 all + -l [0-3] Loglevel, 1 being nothing, 2 being errors, and 3 all -m [1-4] Enable performance overlay, 4 being the most verbose -g Use feral's gamemode -s Use gamescope -d Dryrun, shows you errors in config -b Use BindToInterface to block wan activity - -f [profile] Use firejail for sandboxing games + -f Use firejail for sandboxing games EOF } @@ -164,7 +164,7 @@ parse_opts() shift fi - while getopts ":r:m:il:gsfdb" f + while getopts "r:m:il:gsf:bd" f do case "$f" in r) @@ -174,13 +174,13 @@ parse_opts() die "$local_config, no such file" ;; m) - mangohud="${OPTARG:-on}" + mangohud="$OPTARG" ;; i) ignore_globalconf=true ;; l) - loglevel="${OPTARG:?l: loglevel cant be empty}" + loglevel="$OPTARG" ;; g) gamemode=on @@ -189,8 +189,7 @@ parse_opts() gamescope=on ;; f) - firejail=on - firejail_prof="$OPTARG" + firejail="$OPTARG" ;; b) bind_interface=on @@ -198,7 +197,7 @@ parse_opts() d) dry_run=true ;; - *) + ?) usage exit 1 ;; -- cgit v1.2.3