From: Jameson Rollins Date: Tue, 19 Oct 2010 04:00:17 +0000 (-0400) Subject: fix remove_line function to not use fixed string checking, and to mv -f the tmp file... X-Git-Tag: monkeysphere_0.34-1~1^2~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=eed88e101708058baa6656380b68f826340eb76a;p=monkeysphere.git fix remove_line function to not use fixed string checking, and to mv -f the tmp file into place --- diff --git a/src/share/common b/src/share/common index 8c21a83..d286145 100644 --- a/src/share/common +++ b/src/share/common @@ -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