From: Jameson Graef Rollins Date: Mon, 2 Mar 2009 17:45:48 +0000 (-0500) Subject: fix remove_monkeysphere_line function to properly handle empty files. X-Git-Tag: monkeysphere_0.24~20 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=bd5aac0e2eae2dd73c35b6bbb2e79ef48c98ca21;p=monkeysphere.git fix remove_monkeysphere_line function to properly handle empty files. --- diff --git a/src/share/common b/src/share/common index 83f2d6f..83120d1 100644 --- a/src/share/common +++ b/src/share/common @@ -354,12 +354,15 @@ remove_monkeysphere_lines() { file="$1" - if [ -z "$file" ] ; then + # return error if file does not exist + if [ ! -e "$file" ] ; then return 1 fi - if [ ! -e "$file" ] ; then - return 1 + # just return ok if the file is empty, since there aren't any + # lines to remove + if [ ! -s "$file" ] ; then + return 0 fi tempfile=$(mktemp "${file}.XXXXXXX") || \