add quiet flag
[cedit] / cedit
diff --git a/cedit b/cedit
index dfee11d592c78d1e64b7442fa8a003161c621922..62331b48c85808fefb44d1866cfec7218484784c 100755 (executable)
--- a/cedit
+++ b/cedit
@@ -24,6 +24,7 @@ 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
 -v         Verbose
 -b         Keep backup file
 -h|--help  Help"
@@ -32,10 +33,12 @@ section. cedit is short for config edit.
   local exists=true
   local verbose=false
   local backup=false
+  local quiet=false
 
   case $1 in
     -b) backup=true; shift ;;
     -v) verbose=true; shift ;;
+    -q) quiet=true; shift ;;
     -h|--help) echo "$help"; return ;;
   esac
 
@@ -115,7 +118,7 @@ section. cedit is short for config edit.
   elif type -t diff &>/dev/null; then
     diff=$(diff -u "$temp" "$file")
     ret=$?
-    if (( $ret )); then
+    if (( $ret )) && ! $quiet; then
       echo "backup of original at $temp"
       echo diff -u "$temp" "$file":
       echo "$diff"
@@ -130,8 +133,8 @@ section. cedit is short for config edit.
       echo "$diff"
     fi
   fi
-  if ! $backup; then
-    rm -r $"$temp"
+  if ! $backup && $exists; then
+    rm -r "$temp"
   fi
   return $ret
 }