diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-27 12:50:54 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-27 12:50:54 +0200 |
commit | cf31b107005e5342cd181277be35f570247a70f6 (patch) | |
tree | 2bc4e87dce1f3cd978bea1f254ec48b6faa71ef6 /bin/menuscripts | |
parent | f2633b8d228ddc78a4996822770387ec34687f45 (diff) |
[commander] added verbose option
Diffstat (limited to 'bin/menuscripts')
-rwxr-xr-x | bin/menuscripts/commander | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/menuscripts/commander b/bin/menuscripts/commander index 028e8a7..78a27c9 100755 --- a/bin/menuscripts/commander +++ b/bin/menuscripts/commander @@ -21,7 +21,12 @@ numbered prefix' cleanup() { rm -f "$tmp"; } -logn() { >&2 printf '%s\n' "$@"; } + +logn() +{ + [ "${log_on:=0}" -eq 0 ] && return + >&2 printf '%s\n' "$@" +} run() { IFS=: @@ -240,7 +245,7 @@ main() do eval "$option=0" done - while getopts ":cdhilop:nrsx" opt + while getopts ":cdhilop:nrsxv" opt do # shellcheck disable=SC2034 case $opt in @@ -266,6 +271,7 @@ main() s) instant=1 ;; # invert prefix matching x) prefix=1 ;; + v) log_on=1 ;; :) logn "Option '-$OPTARG' requires an argument" @@ -300,11 +306,11 @@ main() if command -v pre_cmd > /dev/null then pre_cmd > "$tmp" - >&2 printf "menuopts: %s\n" "$menuopts" + logn "menuopts: $menuopts" # shellcheck disable=SC2086 pre_filter < "$tmp" | menucmd $menuopts | post_filter else - >&2 printf "menuopts: %s\n" "$menuopts" + logn "menuopts: $menuopts" # shellcheck disable=SC2086 pre_filter | menucmd $menuopts | post_filter fi |