* config/general.m4sh (sed_double_backslash): Improve this sed

expression to correct left anchored $ input to
double_quote_subst, as well as backslash escaped $ preceded by
any odd-numbered amount of  characters.
This commit is contained in:
Noah Misch 2004-10-21 16:54:54 +00:00 committed by Gary V. Vaughan
parent ff7eac153d
commit 443bae7dd9
2 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2004-10-21 Noah Misch <noah@cs.caltech.edu>,
Gary V. Vaughan <gary@gnu.org>
* config/general.m4sh (sed_double_backslash): Improve this sed
expression to correct left anchored \$ input to
double_quote_subst, as well as backslash escaped $ preceded by
any odd-numbered amount of \ characters.
2004-10-20 Gary V. Vaughan <gary@gnu.org>
* config/general.m4sh (sed_double_backslash): New sed expression

View File

@ -94,12 +94,14 @@ sed_quote_subst='s/\([[`"$\\]]\)/\\\1/g'
# Same as above, but do not quote variable references.
double_quote_subst='s/\([["`\\]]\)/\\\1/g'
# Save mangling of backslash escaped dollars by the above. Running this
# substitution after double_quote_subst notices and corrects expansion
# of already escaped meta-chars. \$x -> double_quote_subst -> \\$x,
# which doesn't protect $x from expansion. To correct this we do:
# \\$x -> sed_double_backslash -> \\\$x, properly protecting $x.
sed_double_backslash='s/\([[^\\]]\)\\\\$/\1\\\\\\$/g'
# Re-`\' parameter expansions in output of double_quote_subst that were
# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
# in input to double_quote_subst, that '$' was protected from expansion.
# Since each input `\' is now two `\'s, look for any number of runs of
# four `\'s followed by two `\'s and then a '$'. `\' that '$'. Note
# that the embedded single quotes serve only to enhance readability.
sed_double_backslash='s/^\(\(''\\\\''\\\\''\)*''\\\\''\$\)/\\\1/;
s/\([[^\\]]\(''\\\\''\\\\''\)*''\\\\''\$\)/\\\1/g'
# test EBCDIC or ASCII
case `$ECHO A|tr A '\301'` in