more changes for here-docs and $'...'; command optimization updates

This commit is contained in:
Chet Ramey
2022-01-31 09:53:03 -05:00
parent 6e1ab9a367
commit b325b0e96b
20 changed files with 423 additions and 56 deletions
+28
View File
@@ -142,3 +142,31 @@ w
x
y
z
=====
WORKS
done
WORKS
a
b
c
d
a
b
c
d
e
A
B
c
d
c
d
e
x
y
z
WORKS
w
x
y
z
+17
View File
@@ -45,3 +45,20 @@ $THIS_SH -c '$binecho c && $binecho d && echo e'
$THIS_SH -c 'trap "echo WORKS" EXIT ; $binecho x ; $binecho y ; $binecho z'
${THIS_SH} -c 'echo w ; { echo x ; $binecho y; }; $binecho z'
echo =====
( trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ )
( trap "echo WORKS && rm $TMPDIR/x$$" EXIT && touch $TMPDIR/x$$ ; $binecho done )
( echo a && { $binecho b && $binecho c ; } && echo d )
( echo a && { $binecho b && $binecho c ; } && echo d ; $binecho e )
( echo A && $binecho B )
( $binecho c && echo d )
( $binecho c && $binecho d && echo e )
( trap "echo WORKS" EXIT ; $binecho x ; $binecho y ; $binecho z )
( echo w ; { echo x ; $binecho y; }; $binecho z )
+23 -2
View File
@@ -275,10 +275,31 @@ argv[2] = <b>
[ abc def ghi jkl / abc def ghi jkl ]
[ abc def ghi jkl ]
[ abc def ghi jkl / abc def ghi jkl / abc def ghi jkl ]
5: OK
1: OK
2: $'not'
3: OK
4: OK
5: tOK
OK
OK
5: $'not\ttoo\nbad'
$'not'
OK
tOK
6: $'not\ttoo\nbad'
OKa ' b
OKa ' b
7: OK
8: OKa ' b
9: OKa " b
10: OKa " b
tOK
tOK
tOK
tOK
./posixexp7.sub: line 69: ${'x1'%'t'}: bad substitution
./posixexp7.sub: line 70: ${'x1'%'t'}: bad substitution
./posixexp7.sub: line 73: ${'x1'%'t'}: bad substitution
./posixexp7.sub: line 74: ${'x1'%'t'}: bad substitution
"A"
A
argv[1] = <"A">
+66 -3
View File
@@ -1,13 +1,76 @@
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# test the effect of quotes on the WORD in the posix pattern removal operators
# a here document does not behave the same as double quotes
#
x=notOK
x1=not
cat <<EOF
5: ${x#$'not'}
1: ${x#$'not'}
2: $'not'
3: ${x#"not"}
4: ${x#'not'}
5: ${x#${x1%'t'}}
EOF
echo "${x#'not'}"
echo "${x#$'not'}"
echo "$'not'"
echo "${x#"not"}"
echo "${x#${x1%'t'}}"
cat <<EOF
5: $'not\ttoo\nbad'
6: $'not\ttoo\nbad'
EOF
x=OK$'a\t\'\tb'
echo OK$'a\t\'\tb'
echo "$x"
cat <<EOF
7: ${x%$'a\t\'\tb'}
8: ${x#$'a\t\'\tb'}
EOF
x=OK'a " b'
cat <<EOF
9: ${x#'a " b'}
10: ${x#$'a " b'}
EOF
x=notOK
x1=not
# extquote makes these work
echo "${x#${$'x1'%$'t'}}"
cat <<EOF
${x#${$'x1'%$'t'}}
EOF
echo "${x#${$'x1'%'t'}}"
cat <<EOF
${x#${$'x1'%'t'}}
EOF
# syntax errors
echo "${x#${'x1'%'t'}}"
cat <<EOF
${x#${'x1'%'t'}}
EOF
echo "${x#${'x1'%$'t'}}"
cat <<EOF
${x#${'x1'%$'t'}}
EOF