fix: use sudo when needed master
authorIan Kelling <iank@fsf.org>
Mon, 11 Nov 2024 00:20:49 +0000 (19:20 -0500)
committerIan Kelling <iank@fsf.org>
Mon, 11 Nov 2024 00:20:49 +0000 (19:20 -0500)
cedit

diff --git a/cedit b/cedit
index 9e0b831f848d9600c4a61415783bb0881ee9f409..0a6c0fecd38ae72a8ddbe8316ab002f8667328d8 100755 (executable)
--- a/cedit
+++ b/cedit
@@ -95,14 +95,14 @@ section. cedit is short for config edit.
     local tailn=1
     local temp="$(mktemp -d)/$file_name"
     cp "$file" "$temp"
-    cp /dev/null "$file"
+    $s cp /dev/null "$file"
     while IFS= read -r line; do
       tailn=$(( tailn + 1 ))
       if [[ $line == "$begin" ]]; then
         in_section=true;
         break
       fi
-      printf '%s\n' "$line" >> $file
+      printf '%s\n' "$line" | tee -a $file >/dev/null
     done < "$temp"
   fi