mirror of https://git.tukaani.org/xz.git
xzgrep: Fix compatibility with old shells.
Running the current xzgrep on Slackware 10.1 with GNU bash 3.00.15: xzgrep: line 231: syntax error near unexpected token `;;' On SCO OpenServer 5.0.7 with Korn Shell 93r: syntax error at line 231 : `;;' unexpected Turns out that some old shells don't like apostrophes (') inside command substitutions. For example, the following fails: x=$(echo foo # asdf'zxcv echo bar) printf '%s\n' "$x" The problem was introduced by commits69d1b3fc29
(2022-03-29),bd7b290f3f
(2022-07-18), anda648978b20
(2022-07-19). 5.2.6 is the only stable release that included this problem. Thanks to Kevin R. Bulgrien for reporting the problem on SCO OpenServer 5.0.7 and for providing the fix.
This commit is contained in:
parent
f2d084fe3f
commit
097c7b67ce
|
@ -209,7 +209,7 @@ for i; do
|
||||||
# which prints "binary file matches" to stderr instead of stdout.
|
# which prints "binary file matches" to stderr instead of stdout.
|
||||||
#
|
#
|
||||||
# If reading from stdin, let grep use whatever name it prefers for
|
# If reading from stdin, let grep use whatever name it prefers for
|
||||||
# stdin. With GNU grep it's a locale-specific translated string.
|
# stdin. With GNU grep it is a locale-specific translated string.
|
||||||
if test "x$i" = "x-"; then
|
if test "x$i" = "x-"; then
|
||||||
eval "$grep -H"
|
eval "$grep -H"
|
||||||
else
|
else
|
||||||
|
@ -226,12 +226,12 @@ for i; do
|
||||||
(*'
|
(*'
|
||||||
'* | *'&'* | *'\'* | *'|'*)
|
'* | *'&'* | *'\'* | *'|'*)
|
||||||
# If sed fails, set i to a known safe string to ensure that
|
# If sed fails, set i to a known safe string to ensure that
|
||||||
# failing sed didn't create a half-escaped dangerous string.
|
# failing sed did not create a half-escaped dangerous string.
|
||||||
i=$(printf '%s\n' "$i" | LC_ALL=C sed 's/[&\|]/\\&/g; $!s/$/\\/') ||
|
i=$(printf '%s\n' "$i" | LC_ALL=C sed 's/[&\|]/\\&/g; $!s/$/\\/') ||
|
||||||
i='(unknown filename):';;
|
i='(unknown filename):';;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# $i already ends with a colon so don't add it here.
|
# $i already ends with a colon so do not add it here.
|
||||||
sed_script="s|^|$i|"
|
sed_script="s|^|$i|"
|
||||||
|
|
||||||
# If grep or sed fails, pick the larger value of the two exit statuses.
|
# If grep or sed fails, pick the larger value of the two exit statuses.
|
||||||
|
|
Loading…
Reference in New Issue