Control: tags 1020108 patch Martin Quinson wrote...
> Thanks for any help that could be provided. Greetings from the Karlsruhe BSP. As mentioned earlier, the build failure is a result of grep's new warning messages. Digging closer I realized the current quote_bre() function can no longer used that way: quilt uses the result both for grep (now triggering the messages) and sed's search and replace (where quoting the forward slash is crucial). The patch attached replaces quote_bre() with two new functions quote_bre_grep() and quote_bre_sed(), and adjusts all invocations according to the respective need. Test suite passes now. Cheers, Christoph
--- a/quilt/diff.in +++ b/quilt/diff.in @@ -260,7 +260,7 @@ # Add all files in the snapshot into the file list (they may all # have changed). files=( $(find $QUILT_PC/$snap_subdir -type f \ - | sed -e "s/^$(quote_bre $QUILT_PC/$snap_subdir/)//" \ + | sed -e "s/^$(quote_bre_sed $QUILT_PC/$snap_subdir/)//" \ | sort) ) printf "%s\n" "${files[@]}" >&4 unset files --- a/quilt/patches.in +++ b/quilt/patches.in @@ -71,7 +71,7 @@ # Quote each file name only once for file in "${opt_files[@]}" do - files_bre[${#files_bre[@]}]=$(quote_bre "$file") + files_bre[${#files_bre[@]}]=$(quote_bre_grep "$file") done # "Or" all files in a single pattern --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -91,7 +91,15 @@ } # Quote a string for use in a basic regular expression. -quote_bre() +# For use with grep. +quote_bre_grep() +{ + echo "$1" | sed -e 's:\([][^$.*\\]\):\\\1:g' +} + +# Quote a string for use in a basic regular expression. +# For use with sed's search and replace. +quote_bre_sed() { echo "$1" | sed -e 's:\([][^$/.*\\]\):\\\1:g' } @@ -227,7 +235,7 @@ if [ -e "$SERIES" ] then - grep -q "^$(quote_bre $patch)\([ \t]\|$\)" "$SERIES" + grep -q "^$(quote_bre_grep $patch)\([ \t]\|$\)" "$SERIES" else return 1 fi @@ -377,7 +385,7 @@ { local patch=$1 [ -e $DB ] || return 1 - grep -q "^$(quote_bre $patch)\$" $DB + grep -q "^$(quote_bre_grep $patch)\$" $DB } applied_patches() @@ -477,7 +485,7 @@ local tmpfile if tmpfile=$(gen_tempfile) then - grep -v "^$(quote_bre $patch)\$" $DB > $tmpfile + grep -v "^$(quote_bre_grep $patch)\$" $DB > $tmpfile cat $tmpfile > $DB rm -f $tmpfile [ -s $DB ] || rm -f $DB @@ -542,7 +550,7 @@ fi local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/} - local bre=$(quote_bre "$patch") + local bre=$(quote_bre_sed "$patch") set -- $(sed -e "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\|\.lz\)\([ "$'\t'"]\|$\)/!d" \ -e 's/[ '$'\t''].*//' "$SERIES") if [ $# -eq 1 ] @@ -653,7 +661,7 @@ then find "$path" -type f \ -a ! -path "$(quote_glob "$path")/.timestamp" | - sed -e "s/$(quote_bre "$path")\///" + sed -e "s/$(quote_bre_sed "$path")\///" fi } --- a/quilt/upgrade.in +++ b/quilt/upgrade.in @@ -76,7 +76,7 @@ for patch in $(applied_patches) do - proper_name="$(grep "^$(quote_bre $patch)"'\(\|\.patch\|\.diff?\)\(\|\.gz\|\.bz2\)\([ \t]\|$\)' $SERIES)" + proper_name="$(grep "^$(quote_bre_grep $patch)"'\(\|\.patch\|\.diff?\)\(\|\.gz\|\.bz2\)\([ \t]\|$\)' $SERIES)" proper_name=${proper_name#$QUILT_PATCHES/} proper_name=${proper_name%% *} if [ -z "$proper_name" ] @@ -86,7 +86,7 @@ fi if [ "$patch" != "$proper_name" -a -d $QUILT_PC/$patch ] \ - && grep -q "^$(quote_bre $patch)\$" \ + && grep -q "^$(quote_bre_grep $patch)\$" \ $QUILT_PC/applied-patches then mv $QUILT_PC/$patch $QUILT_PC/$proper_name \