diff options
author | jilles <jilles@FreeBSD.org> | 2010-10-29 19:34:57 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-10-29 19:34:57 +0000 |
commit | aaa3347e35af4d5a78d7159ebddda1f06dbb2275 (patch) | |
tree | e746f39f7e9cc329381f8a5921f6d37f038dd8dc /tools | |
parent | fb52bdc70d3cbdbe376680788e56f06717e7630f (diff) | |
download | FreeBSD-src-aaa3347e35af4d5a78d7159ebddda1f06dbb2275.zip FreeBSD-src-aaa3347e35af4d5a78d7159ebddda1f06dbb2275.tar.gz |
sh: Fix some issues with CTL* bytes and ${var#pat}.
subevalvar() incorrectly assumed that CTLESC bytes were present iff the
expansion was quoted. However, they are present iff various processing such
as word splitting is to be done later on.
Example:
v=@$e@$e@$e@
y="${v##*"$e"}"
echo "$y"
failed if $e contained the magic CTLESC byte.
Exp-run done by: pav (with some other sh(1) changes)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/expansion/trim6.0 | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/trim6.0 b/tools/regression/bin/sh/expansion/trim6.0 new file mode 100644 index 0000000..3f753c4 --- /dev/null +++ b/tools/regression/bin/sh/expansion/trim6.0 @@ -0,0 +1,22 @@ +# $FreeBSD$ + +e= +for i in 0 1 2 3; do + for j in 0 1 2 3 4 5 6 7; do + for k in 0 1 2 3 4 5 6 7; do + case $i$j$k in + 000) continue ;; + esac + e="$e\\$i$j$k" + done + done +done +e=$(printf "$e") +v=@$e@$e@ +y=${v##*"$e"} +yq="${v##*"$e"}" +[ "$y" = @ ] || echo "error when unquoted in non-splitting context" +[ "$yq" = @ ] || echo "error when quoted in non-splitting context" +[ "${v##*"$e"}" = @ ] || echo "error when quoted in splitting context" +IFS= +[ ${v##*"$e"} = @ ] || echo "error when unquoted in splitting context" |