fix remove_line function to not use fixed string checking, and to mv -f the tmp file...
authorJameson Rollins <jrollins@finestructure.net>
Tue, 19 Oct 2010 04:00:17 +0000 (00:00 -0400)
committerJameson Rollins <jrollins@finestructure.net>
Tue, 19 Oct 2010 04:00:17 +0000 (00:00 -0400)
src/share/common

index 8c21a836f5dbb270a84fba00de0c8eb134f0def1..d286145f31481f9b5bf806466979f4e08cdd073e 100644 (file)
@@ -340,14 +340,13 @@ remove_line() {
     fi
 
     # if the string is in the file...
-    if grep -q -F "$string" "$file" 2>/dev/null ; then
+    if grep "$string" "$file" &>/dev/null ; then
        tempfile=$(mktemp "${file}.XXXXXXX") || \
            failure "Unable to make temp file '${file}.XXXXXXX'"
        
        # remove the line with the string, and return 0
-       grep -v -F "$string" "$file" >"$tempfile"
-       cat "$tempfile" > "$file"
-       rm "$tempfile"
+       grep -v "$string" "$file" >"$tempfile"
+       mv -f "$tempfile" "$file"
        return 0
     # otherwise return 1
     else