| 1 | From upstream
|
| 2 | https://git.savannah.nongnu.org/cgit/quilt.git/patch/?id=f73f8d7f71de2878d3f92881a5fcb8eafd78cb5f
|
| 3 |
|
| 4 | From f73f8d7f71de2878d3f92881a5fcb8eafd78cb5f Mon Sep 17 00:00:00 2001
|
| 5 | From: Jean Delvare <[email protected]>
|
| 6 | Date: Fri, 9 Sep 2022 10:10:37 +0200
|
| 7 | Subject: Avoid warnings with grep 3.8
|
| 8 |
|
| 9 | GNU grep version 3.8 became more strict about needless quoting in
|
| 10 | patterns. We have one occurrence of that in quilt, where "/"
|
| 11 | characters are being quoted by default. There are cases where they
|
| 12 | indeed need to be quoted (typically when used in a sed s/// command)
|
| 13 | but most of the time they do not, and this results in the following
|
| 14 | warning:
|
| 15 |
|
| 16 | grep: warning: stray \ before /
|
| 17 |
|
| 18 | So rename quote_bre() to quote_sed_re(), and introduce
|
| 19 | quote_grep_re() which does not quote "/".
|
| 20 |
|
| 21 | Signed-off-by: Jean Delvare <[email protected]>
|
| 22 | ---
|
| 23 | quilt/diff.in | 2 +-
|
| 24 | quilt/patches.in | 2 +-
|
| 25 | quilt/scripts/patchfns.in | 20 +++++++++++++-------
|
| 26 | quilt/upgrade.in | 4 ++--
|
| 27 | 4 files changed, 17 insertions(+), 11 deletions(-)
|
| 28 |
|
| 29 | diff --git a/quilt/diff.in b/quilt/diff.in
|
| 30 | index e90dc33..07788ff 100644
|
| 31 | |
| 32 | |
| 33 | @@ -255,7 +255,7 @@ then
|
| 34 | # Add all files in the snapshot into the file list (they may all
|
| 35 | # have changed).
|
| 36 | files=( $(find $QUILT_PC/$snap_subdir -type f \
|
| 37 | - | sed -e "s/^$(quote_bre $QUILT_PC/$snap_subdir/)//" \
|
| 38 | + | sed -e "s/^$(quote_sed_re $QUILT_PC/$snap_subdir/)//" \
|
| 39 | | sort) )
|
| 40 | printf "%s\n" "${files[@]}" >&4
|
| 41 | unset files
|
| 42 | diff --git a/quilt/patches.in b/quilt/patches.in
|
| 43 | index bb17a46..eac45a9 100644
|
| 44 | |
| 45 | |
| 46 | @@ -60,7 +60,7 @@ scan_unapplied()
|
| 47 | # Quote each file name only once
|
| 48 | for file in "${opt_files[@]}"
|
| 49 | do
|
| 50 | - files_bre[${#files_bre[@]}]=$(quote_bre "$file")
|
| 51 | + files_bre[${#files_bre[@]}]=$(quote_grep_re "$file")
|
| 52 | done
|
| 53 |
|
| 54 | # "Or" all files in a single pattern
|
| 55 | diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
|
| 56 | index c2d5f9d..1bd7233 100644
|
| 57 | |
| 58 | |
| 59 | @@ -78,8 +78,14 @@ array_join()
|
| 60 | done
|
| 61 | }
|
| 62 |
|
| 63 | -# Quote a string for use in a basic regular expression.
|
| 64 | -quote_bre()
|
| 65 | +# Quote a string for use in a regular expression for a grep pattern.
|
| 66 | +quote_grep_re()
|
| 67 | +{
|
| 68 | + echo "$1" | sed -e 's:\([][^$.*\\]\):\\\1:g'
|
| 69 | +}
|
| 70 | +
|
| 71 | +# Quote a string for use in a regular expression for a sed s/// command.
|
| 72 | +quote_sed_re()
|
| 73 | {
|
| 74 | echo "$1" | sed -e 's:\([][^$/.*\\]\):\\\1:g'
|
| 75 | }
|
| 76 | @@ -215,7 +221,7 @@ patch_in_series()
|
| 77 |
|
| 78 | if [ -e "$SERIES" ]
|
| 79 | then
|
| 80 | - grep -q "^$(quote_bre $patch)\([ \t]\|$\)" "$SERIES"
|
| 81 | + grep -q "^$(quote_grep_re $patch)\([ \t]\|$\)" "$SERIES"
|
| 82 | else
|
| 83 | return 1
|
| 84 | fi
|
| 85 | @@ -365,7 +371,7 @@ is_applied()
|
| 86 | {
|
| 87 | local patch=$1
|
| 88 | [ -e $DB ] || return 1
|
| 89 | - grep -q "^$(quote_bre $patch)\$" $DB
|
| 90 | + grep -q "^$(quote_grep_re $patch)\$" $DB
|
| 91 | }
|
| 92 |
|
| 93 | applied_patches()
|
| 94 | @@ -465,7 +471,7 @@ remove_from_db()
|
| 95 | local tmpfile
|
| 96 | if tmpfile=$(gen_tempfile)
|
| 97 | then
|
| 98 | - grep -v "^$(quote_bre $patch)\$" $DB > $tmpfile
|
| 99 | + grep -v "^$(quote_grep_re $patch)\$" $DB > $tmpfile
|
| 100 | cat $tmpfile > $DB
|
| 101 | rm -f $tmpfile
|
| 102 | [ -s $DB ] || rm -f $DB
|
| 103 | @@ -520,7 +526,7 @@ find_patch()
|
| 104 | fi
|
| 105 |
|
| 106 | local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/}
|
| 107 | - local bre=$(quote_bre "$patch")
|
| 108 | + local bre=$(quote_sed_re "$patch")
|
| 109 | set -- $(sed -e "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\|\.lz\)\([ "$'\t'"]\|$\)/!d" \
|
| 110 | -e 's/[ '$'\t''].*//' "$SERIES")
|
| 111 | if [ $# -eq 1 ]
|
| 112 | @@ -631,7 +637,7 @@ files_in_patch()
|
| 113 | then
|
| 114 | find "$path" -type f \
|
| 115 | -a ! -path "$(quote_glob "$path")/.timestamp" |
|
| 116 | - sed -e "s/$(quote_bre "$path")\///"
|
| 117 | + sed -e "s/$(quote_sed_re "$path")\///"
|
| 118 | fi
|
| 119 | }
|
| 120 |
|
| 121 | diff --git a/quilt/upgrade.in b/quilt/upgrade.in
|
| 122 | index dbf7d05..866aa33 100644
|
| 123 | |
| 124 | |
| 125 | @@ -74,7 +74,7 @@ printf $"Converting meta-data to version %s\n" "$DB_VERSION"
|
| 126 |
|
| 127 | for patch in $(applied_patches)
|
| 128 | do
|
| 129 | - proper_name="$(grep "^$(quote_bre $patch)"'\(\|\.patch\|\.diff?\)\(\|\.gz\|\.bz2\)\([ \t]\|$\)' $SERIES)"
|
| 130 | + proper_name="$(grep "^$(quote_grep_re $patch)"'\(\|\.patch\|\.diff?\)\(\|\.gz\|\.bz2\)\([ \t]\|$\)' $SERIES)"
|
| 131 | proper_name=${proper_name#$QUILT_PATCHES/}
|
| 132 | proper_name=${proper_name%% *}
|
| 133 | if [ -z "$proper_name" ]
|
| 134 | @@ -84,7 +84,7 @@ do
|
| 135 | fi
|
| 136 |
|
| 137 | if [ "$patch" != "$proper_name" -a -d $QUILT_PC/$patch ] \
|
| 138 | - && grep -q "^$(quote_bre $patch)\$" \
|
| 139 | + && grep -q "^$(quote_grep_re $patch)\$" \
|
| 140 | $QUILT_PC/applied-patches
|
| 141 | then
|
| 142 | mv $QUILT_PC/$patch $QUILT_PC/$proper_name \
|
| 143 | --
|
| 144 | cgit v1.1
|
| 145 |
|