From: Ian Kelling Date: Fri, 13 Jan 2023 22:52:07 +0000 (-0500) Subject: add silent mode X-Git-Url: https://iankelling.org/git/?p=cedit;a=commitdiff_plain;h=ea4ea4beebbe3d42e3016c8db246e8ad7d4aa20e add silent mode --- diff --git a/cedit b/cedit index 62331b4..e6d373c 100755 --- a/cedit +++ b/cedit @@ -25,20 +25,23 @@ section. Without SECTION_NAME, it acts on a global unnamed section. cedit is short for config edit. -q Quiet +-s Silent. Quiet and exit 0 on modified file. -v Verbose -b Keep backup file -h|--help Help" - local s diff name init - local file_dir="$(dirname "$file")" - local exists=true - local verbose=false - local backup=false - local quiet=false + local s diff name init file_dir exists verbose backup quiet silent + file_dir="$(dirname "$file")" + exists=true + verbose=false + backup=false + quiet=false + silent=false case $1 in -b) backup=true; shift ;; -v) verbose=true; shift ;; -q) quiet=true; shift ;; + -s) quiet=true; silent=true; shift ;; -h|--help) echo "$help"; return ;; esac @@ -136,6 +139,13 @@ section. cedit is short for config edit. if ! $backup && $exists; then rm -r "$temp" fi - return $ret + if $silent; then + case $ret in + 0|1) return 0 ;; + *) return $ret ;; + esac + else + return $ret + fi } cedit "$@"