ash: add tests adapted from hush glob tests. glob2.tests currently fails

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2015-09-04 03:27:08 +02:00
parent 68acc0f835
commit 66a781acb9
8 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,2 @@
glob1.tests
glob1.tests

View File

@ -0,0 +1,2 @@
echo *glob1?t[e]sts*
echo "glob1"?'t'[e]s*

View File

@ -0,0 +1,18 @@
Expected Actual
Z\* : Z\*
Z* : Z*
Z\f : Z\f
Z\* : Z\*
Z\z : Z\z
Zz : Zz
Z\z : Z\z
Z\z : Z\z
Z\ : Z\
Z\ : Z\
Z\f Zf : Z\f Zf
Z\f Zf : Z\f Zf
Done: 0

View File

@ -0,0 +1,27 @@
# This test demonstrates that in unquoted $v, backslashes expand by this rule:
# \z -> \\\z; \<eol> -> \\<eol> (for any z, special or not),
# and subsequently globbing converts \\ to \ and treats \z as literal z
# even if it is a special char.
>'Zf'
>'Z\f'
echo 'Expected' 'Actual'
v='\*'; echo 'Z\* :' Z$v # ash is buggy here: prints 'Z\f'
echo 'Z* :' Z\*
echo 'Z\f :' Z\\*
echo 'Z\* :' Z\\\* # NB! only this matches Z$v output
echo
v='\z'; echo 'Z\z :' Z$v
echo 'Zz :' Z\z
echo 'Z\z :' Z\\z
echo 'Z\z :' Z\\\z
echo
v='\'; echo 'Z\ :' Z$v
echo 'Z\ :' Z\\
echo
v='*'; echo 'Z\f Zf :' Z$v
echo 'Z\f Zf :' Z*
echo
rm 'Z\f' 'Zf'
echo Done: $?

View File

@ -0,0 +1,6 @@
ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp
ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp
*.tmp
ZVAR=z.tmp z.tmp
ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp
ZVAR=z.tmp ZVAR=*.tmp ZVAR=[z].tmp

View File

@ -0,0 +1,10 @@
>ZVAR=z.tmp
>z.tmp
ZVAR=*.tmp echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp"
ZVAR=*.tmp /bin/echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp"
ZVAR=*.tmp
echo "$ZVAR"
echo $ZVAR
echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp"
/bin/echo ZVAR=*.tmp "ZVAR=*.tmp" "ZVAR=[z].tmp"
rm ZVAR=z.tmp z.tmp

View File

@ -0,0 +1,2 @@
z.tmp:
?.tmp: TEST

View File

@ -0,0 +1,9 @@
# Redirections are not globbed.
# bash:
# if run as "sh", they are not globbed, but
# if run as "bash", they are!
>z.tmp
echo TEST >?.tmp
echo 'z.tmp:' `cat 'z.tmp'`
echo '?.tmp:' `cat '?.tmp'`
rm 'z.tmp' '?.tmp'