add option to not alter exit status on modification
[cedit] / cedit
diff --git a/cedit b/cedit
index 1cfa5803c08cdb13945b8ae81fa882f747bcfc89..9e0b831f848d9600c4a61415783bb0881ee9f409 100755 (executable)
--- a/cedit
+++ b/cedit
@@ -22,7 +22,7 @@
 
 cedit() {
   local help="Usage: [-h|--help ] [-v] [SECTION_NAME] FILE
-Create/modify a section in a config file
+Create/modify a comment-delimited section in a config file
 
 Returns 1 if the file is modified by this command, 2 or higher
 for other problems.
@@ -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 ;;