On Wed, 19 Feb 2025 14:32:11 +0100, Daniel Wagner wrote: > On Wed, Feb 19, 2025 at 02:14:12PM +0100, Jean Delvare wrote: > > What problem were you trying to solve in the first place? > > SUSE's downstream version of quilt for managing kernel trees there is a > patch which exchanges an awk script with a sed. I tried to transfer the > sed expression back to the awk but failed. Can't really figure out why. > > Sed part fails in the test suite where strange file names are tested. > With my change all tests pass. > > -› › awk ' > -› › /^[[:space:]]*'"$(quote_awk_re $before)"'([ \t]|$)/ \ > -› › › › { > -› › › › › match($0, > "^([[:space:]]*)'"$(quote_awk_re $before | sed -e 's:\\:\\\\:g')"'([ \t]|$)", > a) > -› › › › › print a[1] "'"$patch$patch_args"'" > -› › › › } > -› › › › { print } > -› › ' "$SERIES" > $tmpfile > +› › sed -Ee 's/^([[:space:]]*)'"$(quote_sed_re $after)"'([ > \t]|$).*$/&\n\1'"$(quote_sed_re $patch$patch_args)"'/' \ > +› › › "$SERIES" > $tmpfile
This is sed -E, not sed. So it uses extended regular expressions, which have different rules as to which characters must be escaped and which must not. This explains why quote_sed_re() doesn't work. You'd either need a separate helper function to quote sed -E extended regular expressions, or to rewrite the regexp above to be a basic (not extended) regular expression. -- Jean Delvare SUSE L3 Support _______________________________________________ Quilt-dev mailing list Quilt-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/quilt-dev