diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:33:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:33:23 +0000 |
commit | 1d5cace9db9aef76f26b2d7ba54bbb76443b00b2 (patch) | |
tree | 314a15dd1aa103da13bdc83ba1d2105a290bc5ba /tests/posixexp.tests | |
parent | Initial commit. (diff) | |
download | bash-89791e9f494bebe33a9c52292a98f4f079926078.tar.xz bash-89791e9f494bebe33a9c52292a98f4f079926078.zip |
Adding upstream version 5.0.upstream/5.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/posixexp.tests')
-rw-r--r-- | tests/posixexp.tests | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/posixexp.tests b/tests/posixexp.tests new file mode 100644 index 0000000..3368711 --- /dev/null +++ b/tests/posixexp.tests @@ -0,0 +1,83 @@ +unset a +printf "%s\n" ${a:=a\ b} +echo "$a" + +unset v +recho ${v=a\ b} x ${v=c\ d} + +unset v +recho "${v=a\ b}" x "${v=c\ d}" + +unset a v + +recho "foo ${IFS+'bar'} baz" +recho "a ${IFS+b c} d" + +recho "a ${IFS+"b c"} d" + +u=x +recho "foo ${IFS+a$u{{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz + +a=foo +recho "${IFS+'$a'}" +recho "${IFS+"'$a'"}" + +recho ${IFS+'$a'} +recho ${IFS+"'$a'"} + +unset a u +x='foo*bar' + +recho "${x##"}"}" +recho "${x##'}'}" +recho "${x##'}" + +recho "${x:-'}'}" + +foo="x'a'y" +recho "${foo%*'a'*}" +unset x + +unset u +v=w +printf '<%s> ' ${u+x} . ${v+x} . "${u+x}" . "${v+x}" .; echo +printf '<%s> ' ${u-x} . ${v-x} . "${u-x}" . "${v-x}" .; echo +printf '<%s> ' ${u=x} . ${v=x} . "${u=x}" . "${v=x}" .; echo +printf '<%s> ' ${u?x} . ${v?x} . "${u?x}" . "${v?x}" .; echo +printf '<%s> ' ${u#x} . ${v#x} . "${u#x}" . "${v#x}" .; echo +printf '<%s> ' ${u%x} . ${v%x} . "${u%x}" . "${v%x}" .; echo +printf '<%s> ' ${u:+x} . ${v:+x} . "${u:+x}" . "${v:+x}" .; echo +printf '<%s> ' ${u:-x} . ${v:-x} . "${u:-x}" . "${v:-x}" .; echo +printf '<%s> ' ${u:=x} . ${v:=x} . "${u:=x}" . "${v:=x}" .; echo +printf '<%s> ' ${u:?x} . ${v:?x} . "${u:?x}" . "${v:?x}" .; echo +# these are invalid substitution operators +#printf '<%s> ' ${u:#x} . ${v:#x} . "${u:#x}" . "${v:#x}" .; echo +#printf '<%s> ' ${u:%x} . ${v:%x} . "${u:%x}" . "${v:%x}" .; echo + +unset foo +set -o posix + +recho "${IFS+'bar}" +recho "foo ${IFS+'bar} baz" + +recho ${IFS+'}'z} +recho "${IFS+'}'z}" + +: ${TMPDIR:=/var/tmp} +rm -f $TMPDIR/sh +cp ${THIS_SH} $TMPDIR/sh +THIS_SH=$TMPDIR/sh ${THIS_SH} ./posixexp1.sub || echo "sh posixexp1.sub: test $? failed" +${THIS_SH} ./posixexp1.sub || echo "bash posixexp1.sub: test $? failed" + +THIS_SH=$TMPDIR/sh ${THIS_SH} ./posixexp2.sub || echo "sh posixexp2.sub: test $? failed" +rm -f $TMPDIR/sh + +${THIS_SH} ./posixexp3.sub +${THIS_SH} ./posixexp4.sub +${THIS_SH} ./posixexp5.sub +${THIS_SH} ./posixexp6.sub +${THIS_SH} ./posixexp7.sub + +# this will be an error +foo=bar +echo "${foo:-"a}" |