OSDN Git Service

[IMPROVED] Adapt to the behavior change grep(1) as of 12.0-RELEASE that the case...
[portsreinstall/current.git] / lib / libfileedit.sh
index 6d8a8ef..007ca4e 100644 (file)
@@ -15,7 +15,7 @@ fileedit_rm_a_line ()
        [ -n "$item" ] || return 0
        [ -e "$dstpath" ] || return 0
        tmpfile=$dstpath.fileedit_rm_a_line.tmp
-       grep -v -Fx "$item" "$dstpath" 2> /dev/null > $tmpfile || :
+       env LANG=C grep -v -Fx "$item" "$dstpath" 2> /dev/null > $tmpfile || :
        mv "$tmpfile" "$dstpath"
 }
 
@@ -31,7 +31,7 @@ fileedit_add_a_line_if_new ()
        if [ -e "$dstpath" ]
        then
                cp "$dstpath" "$tmpfile"
-               grep -q -Fx "$item" "$dstpath" \
+               env LANG=C grep -q -Fx "$item" "$dstpath" \
                        || echo "$item" >> $tmpfile
        else
                dstdir=`dirname "$dstpath"`
@@ -77,7 +77,7 @@ fileedit_add_lines_if_new ()
        then
                while read origin
                do
-                       grep -q -Fx "$origin" "$dstpath" \
+                       env LANG=C grep -q -Fx "$origin" "$dstpath" \
                                || echo "$origin"
                done > $tmpclip
                if [ "@$advance" = @advance ]
@@ -110,8 +110,8 @@ fileedit_manipulate_old_new_lines ()
        newdiff=$4
        [ -e "$oldsrc" ] || oldsrc=/dev/null
        [ -e "$newsrc" ] || newsrc=/dev/null
-       grep -vFx -f "$newsrc" "$oldsrc" > $olddiff 2> /dev/null || :
-       grep -vFx -f "$oldsrc" "$newsrc" > $newdiff 2> /dev/null || :
+       env LANG=C grep -vFx -f "$newsrc" "$oldsrc" > $olddiff 2> /dev/null || :
+       env LANG=C grep -vFx -f "$oldsrc" "$newsrc" > $newdiff 2> /dev/null || :
        [ `cat "$olddiff" "$newdiff" | wc -l` -gt 0 ]
 }
 
@@ -123,7 +123,7 @@ fileedit_manipulate_old_lines ()
        newsrc=$2
        [ -e "$oldsrc" ] || oldsrc=/dev/null
        [ -e "$newsrc" ] || newsrc=/dev/null
-       grep -vFx -f "$newsrc" "$oldsrc" 2> /dev/null
+       env LANG=C grep -vFx -f "$newsrc" "$oldsrc" 2> /dev/null
 }
 
 # ============= Manipulate new lines from an old and a new versions of a file =============
@@ -134,7 +134,7 @@ fileedit_manipulate_new_lines ()
        newsrc=$2
        [ -e "$oldsrc" ] || oldsrc=/dev/null
        [ -e "$newsrc" ] || newsrc=/dev/null
-       grep -vFx -f "$oldsrc" "$newsrc" 2> /dev/null
+       env LANG=C grep -vFx -f "$oldsrc" "$newsrc" 2> /dev/null
 }
 
 # ============= Check whether removed lines exists in updating from an old and a new versions of a file =============
@@ -145,5 +145,5 @@ fileedit_exists_old_lines ()
        newsrc=$2
        [ -e "$oldsrc" ] || oldsrc=/dev/null
        [ -e "$newsrc" ] || newsrc=/dev/null
-       grep -qvFx -f "$newsrc" "$oldsrc" 2> /dev/null
+       env LANG=C grep -qvFx -f "$newsrc" "$oldsrc" 2> /dev/null
 }