From 96728d30b3059fea6fd05e17614a72274ddd40f4 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Thu, 30 Jan 2003 11:42:54 +0000 Subject: Fix some regex quoting --- lib/patchfns.in | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/patchfns.in') diff --git a/lib/patchfns.in b/lib/patchfns.in index 17c5b56..de8e715 100644 --- a/lib/patchfns.in +++ b/lib/patchfns.in @@ -30,7 +30,7 @@ DIFFSTAT=/usr/bin/diffstat quote_re() { - echo "$1" | sed -e 's:\([/.+*\[\\]\):\\\1:g' + echo "$1" | sed -e 's:\([^$/.+*\[\\]\):\\\1:g' } #basename() @@ -140,7 +140,7 @@ patch_in_series() then return 1 else - grep -q '^'"$(quote_re $patch)"'\(\|\.patch\|.diff\?\)\(\|\.gz\|\.bz2\)\([ \t]\|$\)' $SERIES + grep -q -E '^'"$(quote_re $patch)"'(|\.patch|\.diff?)(|\.gz|\.bz2)([ \t]|$)' $SERIES fi } @@ -237,7 +237,7 @@ top_patch() is_numeric() { - echo $1 | grep -q -e '^[0-9]*$' + echo $1 | grep -q '^[0-9]*$' } is_applied_last() @@ -250,7 +250,7 @@ is_applied() { local patch=$1 [ -e $DB ] || return 1 - grep -q "^$patch\$" $DB + grep -q -E "^$(quote_re $patch)\$" $DB } patches_before() @@ -302,8 +302,8 @@ next_patch_for_file() if [ -n "$patches_on_top" ] then - grep -l -e "^$(quote_re $file)\$" \ - $(pc_file_name $patches_on_top) \ + grep -l -E "^$(quote_re $file)\$" \ + $(pc_file_name $patches_on_top) \ | head -1 \ | sed -e 's:^\.pc/::' -e 's:/\.pc$::' fi @@ -420,7 +420,7 @@ remove_from_db() local tmpfile if tmpfile=$(mktemp /tmp/patch-scripts.XXXXXX) then - grep -v "^$(quote_re $patch)\$" $DB > $tmpfile + grep -v -E "^$(quote_re $patch)\$" $DB > $tmpfile mv -f $tmpfile $DB rm -f $tmpfile [ -s $DB ] || rm -f $DB @@ -442,7 +442,8 @@ stripit() file_in_patch() { local file=$1 patch=$2 - files_in_patch $patch | grep -q "^$file\$" + files_in_patch $patch \ + | grep -q -E "^$(quote_re $file)\$" } files_in_patch() -- cgit