From: Ian Kelling Date: Mon, 20 May 2024 22:07:58 +0000 (-0400) Subject: add option to not alter exit status on modification X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=26a1849cd31a766d6fbe04ed223b88237543908a;p=cedit add option to not alter exit status on modification --- diff --git a/cedit b/cedit index e47afa5..9e0b831 100755 --- a/cedit +++ b/cedit @@ -31,10 +31,11 @@ The section is #comment delimited. Reads STDIN for the contents of the section. Without SECTION_NAME, it acts on a global unnamed section. cedit is short for config edit. --q Quiet +-b Keep backup file +-e Exit 0 on modified file. -s Silent. Quiet and exit 0 on modified file. +-q Quiet -v Verbose --b Keep backup file -h|--help Help" local s diff name init file_dir exists verbose backup quiet silent file_dir="$(dirname "$file")" @@ -43,12 +44,14 @@ section. cedit is short for config edit. backup=false quiet=false silent=false + exit_status=true case $1 in -b) backup=true; shift ;; - -v) verbose=true; shift ;; + -e) exit_status=false; shift ;; + -s) quiet=true; silent=true; exit_status=false; shift ;; -q) quiet=true; shift ;; - -s) quiet=true; silent=true; shift ;; + -v) verbose=true; shift ;; -h|--help) echo "$help"; return ;; esac @@ -153,7 +156,7 @@ section. cedit is short for config edit. if ! $backup && $exists; then rm -r "$temp" fi - if $silent; then + if ! $exit_status; then case $ret in 0|1) return 0 ;; *) return $ret ;;