add option to not alter exit status on modification master
authorIan Kelling <iank@fsf.org>
Mon, 20 May 2024 22:07:58 +0000 (18:07 -0400)
committerIan Kelling <iank@fsf.org>
Mon, 20 May 2024 22:07:58 +0000 (18:07 -0400)
cedit

diff --git a/cedit b/cedit
index e47afa5f749407087a25259c027c612262bd7265..9e0b831f848d9600c4a61415783bb0881ee9f409 100755 (executable)
--- 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 ;;