Control: tags -1 patch Control: forcemerge -1 1020487 Hi,
I have started the process of salvaging src:ucf[1]. I think using fixed grep strings which obviate the need to escape the file paths is a better approach. My initial suggested patch is attached which fixes the warnings with DEB_GREP_ENABLE_STRAY_BACKSLASH_WARN=1 set in the environment. Comments? Thanks Mark [1] https://bugs.debian.org/1086847
>From dd65647213b5b091bb94a454d7a579b57db0a3fe Mon Sep 17 00:00:00 2001 From: Mark Hindley <[email protected]> Date: Thu, 7 Nov 2024 17:58:11 +0000 Subject: [PATCH] Use grep fixed strings to avoid need for escaping. Closes: #1019326 --- ucf | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/ucf b/ucf index 4c896d8..76ec4b6 100755 --- a/ucf +++ b/ucf @@ -208,12 +208,12 @@ purge_md5sum () { if [ "X$docmd" = "XYES" ]; then set +e if [ "X$VERBOSE" != "X" ]; then - echo >&2 "grep -Ev [[:space:]]${safe_dest_file}$ $statedir/hashfile" - grep -Ev "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" >&2 \ + echo >&2 "grep -Fv ${dest_file} $statedir/hashfile" + grep -Fv " ${dest_file}${nl}" "$statedir/hashfile" >&2 \ || true; fi - #echo "grep -Ev [[:space:]]${safe_dest_file}$ $statedir/hashfile" - grep -Ev "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" > \ + #echo "grep -Fv ${dest_file} $statedir/hashfile" + grep -Fv " ${dest_file}${nl}" "$statedir/hashfile" > \ "$statedir/hashfile.tmp" || true; if [ "X$docmd" = "XYES" ]; then mv -f "$statedir/hashfile.tmp" "$statedir/hashfile" @@ -250,18 +250,18 @@ replace_md5sum () { if [ "X$docmd" = "XYES" ]; then set +e if [ "X$VERBOSE" != "X" ]; then - echo >&2 "(grep -Ev \"[[:space:]]${safe_dest_file}$\" \"$statedir/hashfile\";" - grep -Ev "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" >&2 || true; + echo >&2 "(grep -Fv \" ${dest_file}\" \"$statedir/hashfile\";" + grep -Fv " ${dest_file}${nl}" "$statedir/hashfile" >&2 || true; md5sum "$orig_new_file" | sed "s|$orig_new_file|$dest_file|" >&2; fi - grep -Ev "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" > \ + grep -Fv " ${dest_file}${nl}" "$statedir/hashfile" > \ "$statedir/hashfile.tmp" || true; md5sum "$orig_new_file" | sed "s|$orig_new_file|$dest_file|" >> \ "$statedir/hashfile.tmp"; mv -f "$statedir/hashfile.tmp" "$statedir/hashfile" set -e else - echo "(grep -Ev \"[[:space:]]${safe_dest_file}$\" \"$statedir/hashfile\"" + echo "(grep -Fv \" ${dest_file}\" \"$statedir/hashfile\"" echo " md5sum \"$orig_new_file\" | sed \"s|$orig_new_file|$dest_file|\"; " echo ") | sort > \"$statedir/hashfile\"" fi @@ -336,7 +336,8 @@ DEBUG=0 VERBOSE='' statedir='/var/lib/ucf'; THREEWAY= - +nl=' +' DIST_SUFFIX="ucf-dist" NEW_SUFFIX="ucf-new" OLD_SUFFIX="ucf-old" @@ -448,8 +449,6 @@ if [ -n "$divert_line" ]; then dest_file=$(dpkg-divert --truename "$dest_file") fi fi -safe_dest_file=$(echo "$dest_file" | perl -nle 'print "\Q$_\E\n"') - ###################################################################### ######## ######### @@ -581,10 +580,10 @@ fi if [ -e "$statedir/hashfile" ]; then if [ "X$VERBOSE" != "X" ]; then echo >&2 "The hash file exists" - echo >&2 "grep -E" "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" - grep -E "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" >&2 || true + echo >&2 "grep -F" " ${dest_file}" "$statedir/hashfile" + grep -F " ${dest_file}${nl}" "$statedir/hashfile" >&2 || true fi - lastsum=$(grep -E "[[:space:]]${safe_dest_file}$" "$statedir/hashfile" | \ + lastsum=$(grep -F " ${dest_file}${nl}" "$statedir/hashfile" | \ awk '{print $1;}' ) fi @@ -604,7 +603,7 @@ cached_file="$(echo $dest_file | tr / :)" if [ $DEBUG -gt 0 ]; then cat >&2 <<EOF The new start file is \`$new_file\' -The destination is \`$dest_file\' (\`$safe_dest_file\') +The destination is \`$dest_file\' The history is kept under \'$source_dir\' The file may be cached at \'$statedir/cache/$cached_file\' EOF -- 2.39.5

