Import OpenBSD 3.3 source repository from CTM 3132 the first time
This opens an OpenBSD-mirabile (aka MirBSD) repository. ### MirBSD is: # Copyright (c) 1982-2003 by Thorsten "mirabile" Glaser <x86@ePost.de> # Copyright © 1968-2003 The authors of And contributors to UNIX®, the # C Language, BSD/Berkeley Unix; 386BSD, NetBSD 1.1 and OpenBSD. # # Anyone who obtained a copy of this work is hereby permitted to freely use, # distribute, modify, merge, sublicence, give away or sell it as long as the # authors are given due credit and the following notice is retained: # # This work is provided "as is", with no explicit or implicit warranty what- # soever. Use it only at your own risk. In no event may an author or contri- # butor be held liable for any damage, directly or indirectly, that origina- # ted through or is caused by creation or modification of this work. MirBSD is my private tree. MirBSD does not differ very much from OpenBSD and intentionally tracks OpenBSD. That's why it _is_ OpenBSD, just not the official one. It's like with DarrenBSD. At time of this writing, no advertising for MirBSD must be done, because the advertising clause has not yet been sorted out. http://templeofhate.com/tglaser/MirBSD/index.php
This commit is contained in:
22
tests/README
Normal file
22
tests/README
Normal file
@@ -0,0 +1,22 @@
|
||||
Tests can be assigned categories to restrict what program they
|
||||
are applied to (eg, pdksh, ksh88, etc.). The following are
|
||||
a list of names to be used for various shells (to keep things
|
||||
consistent):
|
||||
|
||||
sh generic any v7 bourne shell like thing
|
||||
sh-v generic any system V bourne shell like thing
|
||||
ksh generic any ksh
|
||||
posix generic basic posix shell
|
||||
posix-upu generic `user portability utility' options
|
||||
sh-v7 specific the real v7 bourne shell
|
||||
sh-sysv specific the real sysv bourne shell
|
||||
pdksh specific public domain ksh
|
||||
ksh88 specific at&t ksh88
|
||||
ksh93 specific at&t ksh93
|
||||
bash specific GNU bourne-again shell
|
||||
|
||||
The idea is to categorize all the tests according to the `best match'
|
||||
(most generic thing). All generics that apply should be specified.
|
||||
Generally, at most one specific shell will be given.
|
||||
|
||||
At the moment, most (all) tests have not been categorized (any volunteers?).
|
112
tests/alias.t
Normal file
112
tests/alias.t
Normal file
@@ -0,0 +1,112 @@
|
||||
name: alias-1
|
||||
description:
|
||||
Check that recursion is detected/avoided in aliases.
|
||||
stdin:
|
||||
alias fooBar=fooBar
|
||||
fooBar
|
||||
exit 0
|
||||
expected-stderr-pattern:
|
||||
/fooBar.*not found.*/
|
||||
---
|
||||
|
||||
name: alias-2
|
||||
description:
|
||||
Check that recursion is detected/avoided in aliases.
|
||||
stdin:
|
||||
alias fooBar=barFoo
|
||||
alias barFoo=fooBar
|
||||
fooBar
|
||||
barFoo
|
||||
exit 0
|
||||
expected-stderr-pattern:
|
||||
/fooBar.*not found.*\n.*barFoo.*not found/
|
||||
---
|
||||
|
||||
name: alias-3
|
||||
description:
|
||||
Check that recursion is detected/avoided in aliases.
|
||||
stdin:
|
||||
alias Echo='echo '
|
||||
alias fooBar=barFoo
|
||||
alias barFoo=fooBar
|
||||
Echo fooBar
|
||||
unalias barFoo
|
||||
Echo fooBar
|
||||
expected-stdout:
|
||||
fooBar
|
||||
barFoo
|
||||
---
|
||||
|
||||
name: alias-4
|
||||
description:
|
||||
Check that alias expansion isn't done on keywords (in keyword
|
||||
postitions).
|
||||
stdin:
|
||||
alias Echo='echo '
|
||||
alias while=While
|
||||
while false; do echo hi ; done
|
||||
Echo while
|
||||
expected-stdout:
|
||||
While
|
||||
---
|
||||
|
||||
name: alias-5
|
||||
description:
|
||||
Check that alias expansion done after alias with trailing space.
|
||||
stdin:
|
||||
alias Echo='echo '
|
||||
alias foo='bar stuff '
|
||||
alias bar='Bar1 Bar2 '
|
||||
alias stuff='Stuff'
|
||||
alias blah='Blah'
|
||||
Echo foo blah
|
||||
expected-stdout:
|
||||
Bar1 Bar2 Stuff Blah
|
||||
---
|
||||
|
||||
name: alias-6
|
||||
description:
|
||||
Check that alias expansion done after alias with trailing space.
|
||||
stdin:
|
||||
alias Echo='echo '
|
||||
alias foo='bar bar'
|
||||
alias bar='Bar '
|
||||
alias blah=Blah
|
||||
Echo foo blah
|
||||
expected-stdout:
|
||||
Bar Bar Blah
|
||||
---
|
||||
|
||||
name: alias-7
|
||||
description:
|
||||
Check that alias expansion done after alias with trailing space
|
||||
after a keyword.
|
||||
stdin:
|
||||
alias X='case '
|
||||
alias Y=Z
|
||||
X Y in 'Y') echo is y ;; Z) echo is z ; esac
|
||||
expected-stdout:
|
||||
is z
|
||||
---
|
||||
|
||||
name: alias-8
|
||||
description:
|
||||
Check that newlines in an alias don't cause the command to be lost.
|
||||
stdin:
|
||||
alias foo='
|
||||
|
||||
|
||||
echo hi
|
||||
|
||||
|
||||
|
||||
echo there
|
||||
|
||||
|
||||
'
|
||||
foo
|
||||
expected-stdout:
|
||||
hi
|
||||
there
|
||||
---
|
||||
|
79
tests/arith.t
Normal file
79
tests/arith.t
Normal file
@@ -0,0 +1,79 @@
|
||||
name: arith-lazy-1
|
||||
description:
|
||||
Check that only one side of ternary operator is evaluated
|
||||
stdin:
|
||||
x=i+=2
|
||||
y=j+=2
|
||||
typeset -i i=1 j=1
|
||||
echo $((1 ? 20 : (x+=2)))
|
||||
echo $i,$x
|
||||
echo $((0 ? (y+=2) : 30))
|
||||
echo $j,$y
|
||||
expected-stdout:
|
||||
20
|
||||
1,i+=2
|
||||
30
|
||||
1,j+=2
|
||||
---
|
||||
|
||||
name: arith-lazy-2
|
||||
description:
|
||||
Check that assignments not done on non-evaluated side of ternary
|
||||
operator
|
||||
stdin:
|
||||
x=i+=2
|
||||
y=j+=2
|
||||
typeset -i i=1 j=1
|
||||
echo $((1 ? 20 : (x+=2)))
|
||||
echo $i,$x
|
||||
echo $((0 ? (y+=2) : 30))
|
||||
echo $i,$y
|
||||
expected-stdout:
|
||||
20
|
||||
1,i+=2
|
||||
30
|
||||
1,j+=2
|
||||
---
|
||||
|
||||
name: arith-ternary-prec-1
|
||||
description:
|
||||
Check precidance of ternary operator vs assignment
|
||||
stdin:
|
||||
typeset -i x=2
|
||||
y=$((1 ? 20 : x+=2))
|
||||
expected-exit: e != 0
|
||||
expected-stderr-pattern:
|
||||
/.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
|
||||
---
|
||||
|
||||
name: arith-ternary-prec-2
|
||||
description:
|
||||
Check precidance of ternary operator vs assignment
|
||||
stdin:
|
||||
typeset -i x=2
|
||||
echo $((0 ? x+=2 : 20))
|
||||
expected-stdout:
|
||||
20
|
||||
---
|
||||
|
||||
name: arith-div-assoc-1
|
||||
description:
|
||||
Check associativity of division operator
|
||||
stdin:
|
||||
echo $((20 / 2 / 2))
|
||||
expected-stdout:
|
||||
5
|
||||
---
|
||||
|
||||
name: arith-assop-assoc-1
|
||||
description:
|
||||
Check associativity of assignment-operator operator
|
||||
stdin:
|
||||
typeset -i i=1 j=2 k=3
|
||||
echo $((i += j += k))
|
||||
echo $i,$j,$k
|
||||
expected-stdout:
|
||||
6
|
||||
6,5,3
|
||||
---
|
||||
|
341
tests/bksl-nl.t
Normal file
341
tests/bksl-nl.t
Normal file
@@ -0,0 +1,341 @@
|
||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||
|
||||
#
|
||||
# These tests deal with how \newline is handled in various situations. The
|
||||
# first group of tests are places where it shouldn't be collapsed, the next
|
||||
# group of tests are places where it should be collapsed.
|
||||
#
|
||||
name: bksl-nl-ign-1
|
||||
description:
|
||||
Check that \newline is not collasped after #
|
||||
stdin:
|
||||
echo hi #there \
|
||||
echo folks
|
||||
expected-stdout:
|
||||
hi
|
||||
folks
|
||||
---
|
||||
|
||||
name: bksl-nl-ign-2
|
||||
description:
|
||||
Check that \newline is not collasped inside single quotes
|
||||
stdin:
|
||||
echo 'hi \
|
||||
there'
|
||||
echo folks
|
||||
expected-stdout:
|
||||
hi \
|
||||
there
|
||||
folks
|
||||
---
|
||||
|
||||
name: bksl-nl-ign-3
|
||||
description:
|
||||
Check that \newline is not collasped inside single quotes
|
||||
stdin:
|
||||
cat << \EOF
|
||||
hi \
|
||||
there
|
||||
EOF
|
||||
expected-stdout:
|
||||
hi \
|
||||
there
|
||||
---
|
||||
|
||||
name: blsk-nl-ign-4
|
||||
description:
|
||||
Check interaction of aliases, single quotes and here-documents
|
||||
with backslash-newline
|
||||
(don't know what posix has to say about this)
|
||||
stdin:
|
||||
a=2
|
||||
alias x='echo hi
|
||||
cat << "EOF"
|
||||
foo\
|
||||
bar
|
||||
some'
|
||||
x
|
||||
more\
|
||||
stuff$a
|
||||
EOF
|
||||
expected-stdout:
|
||||
hi
|
||||
foo\
|
||||
bar
|
||||
some
|
||||
more\
|
||||
stuff$a
|
||||
---
|
||||
|
||||
name: blsk-nl-ign-5
|
||||
description:
|
||||
Check what happens with backslash at end of input
|
||||
(the old bourne shell trashes them; so do we)
|
||||
stdin: !
|
||||
echo `echo foo\\`bar
|
||||
echo hi\
|
||||
expected-stdout:
|
||||
foobar
|
||||
hi
|
||||
---
|
||||
|
||||
|
||||
#
|
||||
# Places \newline should be collapsed
|
||||
#
|
||||
name: bksl-nl-1
|
||||
description:
|
||||
Check that \newline is collasped before, in the middle of, and
|
||||
after words
|
||||
stdin:
|
||||
\
|
||||
echo hi\
|
||||
There, \
|
||||
folks
|
||||
expected-stdout:
|
||||
hiThere, folks
|
||||
---
|
||||
|
||||
name: bksl-nl-2
|
||||
description:
|
||||
Check that \newline is collasped in $ sequences
|
||||
(ksh93 fails this)
|
||||
stdin:
|
||||
a=12
|
||||
ab=19
|
||||
echo $\
|
||||
a
|
||||
echo $a\
|
||||
b
|
||||
echo $\
|
||||
{a}
|
||||
echo ${a\
|
||||
b}
|
||||
echo ${ab\
|
||||
}
|
||||
expected-stdout:
|
||||
12
|
||||
19
|
||||
12
|
||||
19
|
||||
19
|
||||
---
|
||||
|
||||
name: bksl-nl-3
|
||||
description:
|
||||
Check that \newline is collasped in $(..) and `...` sequences
|
||||
(ksh93 fails this)
|
||||
stdin:
|
||||
echo $\
|
||||
(echo foobar1)
|
||||
echo $(\
|
||||
echo foobar2)
|
||||
echo $(echo foo\
|
||||
bar3)
|
||||
echo $(echo foobar4\
|
||||
)
|
||||
echo `
|
||||
echo stuff1`
|
||||
echo `echo st\
|
||||
uff2`
|
||||
expected-stdout:
|
||||
foobar1
|
||||
foobar2
|
||||
foobar3
|
||||
foobar4
|
||||
stuff1
|
||||
stuff2
|
||||
---
|
||||
|
||||
name: bksl-nl-4
|
||||
description:
|
||||
Check that \newline is collasped in $((..)) sequences
|
||||
(ksh93 fails this)
|
||||
stdin:
|
||||
echo $\
|
||||
((1+2))
|
||||
echo $(\
|
||||
(1+2+3))
|
||||
echo $((\
|
||||
1+2+3+4))
|
||||
echo $((1+\
|
||||
2+3+4+5))
|
||||
echo $((1+2+3+4+5+6)\
|
||||
)
|
||||
expected-stdout:
|
||||
3
|
||||
6
|
||||
10
|
||||
15
|
||||
21
|
||||
---
|
||||
|
||||
name: bksl-nl-5
|
||||
description:
|
||||
Check that \newline is collasped in double quoted strings
|
||||
stdin:
|
||||
echo "\
|
||||
hi"
|
||||
echo "foo\
|
||||
bar"
|
||||
echo "folks\
|
||||
"
|
||||
expected-stdout:
|
||||
hi
|
||||
foobar
|
||||
folks
|
||||
---
|
||||
|
||||
name: bksl-nl-6
|
||||
description:
|
||||
Check that \newline is collasped in here document delimiters
|
||||
(ksh93 fails second part of this)
|
||||
stdin:
|
||||
a=12
|
||||
cat << EO\
|
||||
F
|
||||
a=$a
|
||||
foo\
|
||||
bar
|
||||
EOF
|
||||
cat << E_O_F
|
||||
foo
|
||||
E_O_\
|
||||
F
|
||||
echo done
|
||||
expected-stdout:
|
||||
a=12
|
||||
foobar
|
||||
foo
|
||||
done
|
||||
---
|
||||
|
||||
name: bksl-nl-7
|
||||
description:
|
||||
Check that \newline is collasped in double-quoted here-document
|
||||
delimiter.
|
||||
stdin:
|
||||
a=12
|
||||
cat << "EO\
|
||||
F"
|
||||
a=$a
|
||||
foo\
|
||||
bar
|
||||
EOF
|
||||
echo done
|
||||
expected-stdout:
|
||||
a=$a
|
||||
foo\
|
||||
bar
|
||||
done
|
||||
---
|
||||
|
||||
name: bksl-nl-8
|
||||
description:
|
||||
Check that \newline is collasped in various 2+ character tokens
|
||||
delimiter.
|
||||
(ksh93 fails this)
|
||||
stdin:
|
||||
echo hi &\
|
||||
& echo there
|
||||
echo foo |\
|
||||
| echo bar
|
||||
cat <\
|
||||
< EOF
|
||||
stuff
|
||||
EOF
|
||||
cat <\
|
||||
<\
|
||||
- EOF
|
||||
more stuff
|
||||
EOF
|
||||
cat <<\
|
||||
EOF
|
||||
abcdef
|
||||
EOF
|
||||
echo hi >\
|
||||
> /dev/null
|
||||
echo $?
|
||||
i=1
|
||||
case $i in
|
||||
(\
|
||||
x|\
|
||||
1\
|
||||
) echo hi;\
|
||||
;
|
||||
(*) echo oops
|
||||
esac
|
||||
expected-stdout:
|
||||
hi
|
||||
there
|
||||
foo
|
||||
stuff
|
||||
more stuff
|
||||
abcdef
|
||||
0
|
||||
hi
|
||||
---
|
||||
|
||||
name: blsk-nl-9
|
||||
description:
|
||||
Check that \ at the end of an alias is collapsed when followed
|
||||
by a newline
|
||||
(don't know what posix has to say about this)
|
||||
stdin:
|
||||
alias x='echo hi\'
|
||||
x
|
||||
echo there
|
||||
expected-stdout:
|
||||
hiecho there
|
||||
---
|
||||
|
||||
name: blsk-nl-10
|
||||
description:
|
||||
Check that \newline in a keyword is collapsed
|
||||
stdin:
|
||||
i\
|
||||
f true; then\
|
||||
echo pass; el\
|
||||
se echo fail; fi
|
||||
expected-stdout:
|
||||
pass
|
||||
---
|
||||
|
||||
#
|
||||
# Places \newline should be collapsed (ksh extensions)
|
||||
#
|
||||
|
||||
name: blsk-nl-ksh-1
|
||||
description:
|
||||
Check that \newline is collapsed in extended globbing
|
||||
(ksh93 fails this)
|
||||
stdin:
|
||||
xxx=foo
|
||||
case $xxx in
|
||||
(f*\
|
||||
(\
|
||||
o\
|
||||
)\
|
||||
) echo ok ;;
|
||||
*) echo bad
|
||||
esac
|
||||
expected-stdout:
|
||||
ok
|
||||
---
|
||||
|
||||
name: blsk-nl-ksh-2
|
||||
description:
|
||||
Check that \newline is collapsed in ((...)) expressions
|
||||
(ksh93 fails this)
|
||||
stdin:
|
||||
i=1
|
||||
(\
|
||||
(\
|
||||
i=i+2\
|
||||
)\
|
||||
)
|
||||
echo $i
|
||||
expected-stdout:
|
||||
3
|
||||
---
|
||||
|
195
tests/brkcont.t
Normal file
195
tests/brkcont.t
Normal file
@@ -0,0 +1,195 @@
|
||||
name: break-1
|
||||
description:
|
||||
See if break breaks out of loops
|
||||
stdin:
|
||||
for i in a b c; do echo $i; break; echo bad-$i; done
|
||||
echo end-1
|
||||
for i in a b c; do echo $i; break 1; echo bad-$i; done
|
||||
echo end-2
|
||||
for i in a b c; do
|
||||
for j in x y z; do
|
||||
echo $i:$j
|
||||
break
|
||||
echo bad-$i
|
||||
done
|
||||
echo end-$i
|
||||
done
|
||||
echo end-3
|
||||
expected-stdout:
|
||||
a
|
||||
end-1
|
||||
a
|
||||
end-2
|
||||
a:x
|
||||
end-a
|
||||
b:x
|
||||
end-b
|
||||
c:x
|
||||
end-c
|
||||
end-3
|
||||
---
|
||||
|
||||
name: break-2
|
||||
description:
|
||||
See if break breaks out of nested loops
|
||||
stdin:
|
||||
for i in a b c; do
|
||||
for j in x y z; do
|
||||
echo $i:$j
|
||||
break 2
|
||||
echo bad-$i
|
||||
done
|
||||
echo end-$i
|
||||
done
|
||||
echo end
|
||||
expected-stdout:
|
||||
a:x
|
||||
end
|
||||
---
|
||||
|
||||
|
||||
name: break-3
|
||||
description:
|
||||
What if break used outside of any loops
|
||||
(ksh88,ksh93 don't print error messages here)
|
||||
stdin:
|
||||
break
|
||||
expected-stderr-pattern:
|
||||
/.*break.*/
|
||||
---
|
||||
|
||||
|
||||
name: break-4
|
||||
description:
|
||||
What if break N used when only N-1 loops
|
||||
(ksh88,ksh93 don't print error messages here)
|
||||
stdin:
|
||||
for i in a b c; do echo $i; break 2; echo bad-$i; done
|
||||
echo end
|
||||
expected-stdout:
|
||||
a
|
||||
end
|
||||
expected-stderr-pattern:
|
||||
/.*break.*/
|
||||
---
|
||||
|
||||
|
||||
name: break-5
|
||||
description:
|
||||
Error if break argument isn't a number
|
||||
stdin:
|
||||
for i in a b c; do echo $i; break abc; echo more-$i; done
|
||||
echo end
|
||||
expected-stdout:
|
||||
a
|
||||
expected-exit: e != 0
|
||||
expected-stderr-pattern:
|
||||
/.*break.*/
|
||||
---
|
||||
|
||||
|
||||
name: continue-1
|
||||
description:
|
||||
See if continue continues loops
|
||||
stdin:
|
||||
for i in a b c; do echo $i; continue; echo bad-$i ; done
|
||||
echo end-1
|
||||
for i in a b c; do echo $i; continue 1; echo bad-$i; done
|
||||
echo end-2
|
||||
for i in a b c; do
|
||||
for j in x y z; do
|
||||
echo $i:$j
|
||||
continue
|
||||
echo bad-$i-$j
|
||||
done
|
||||
echo end-$i
|
||||
done
|
||||
echo end-3
|
||||
expected-stdout:
|
||||
a
|
||||
b
|
||||
c
|
||||
end-1
|
||||
a
|
||||
b
|
||||
c
|
||||
end-2
|
||||
a:x
|
||||
a:y
|
||||
a:z
|
||||
end-a
|
||||
b:x
|
||||
b:y
|
||||
b:z
|
||||
end-b
|
||||
c:x
|
||||
c:y
|
||||
c:z
|
||||
end-c
|
||||
end-3
|
||||
---
|
||||
|
||||
|
||||
name: continue-2
|
||||
description:
|
||||
See if continue breaks out of nested loops
|
||||
stdin:
|
||||
for i in a b c; do
|
||||
for j in x y z; do
|
||||
echo $i:$j
|
||||
continue 2
|
||||
echo bad-$i-$j
|
||||
done
|
||||
echo end-$i
|
||||
done
|
||||
echo end
|
||||
expected-stdout:
|
||||
a:x
|
||||
b:x
|
||||
c:x
|
||||
end
|
||||
---
|
||||
|
||||
|
||||
name: continue-3
|
||||
description:
|
||||
What if continue used outside of any loops
|
||||
(ksh88,ksh93 don't print error messages here)
|
||||
stdin:
|
||||
continue
|
||||
expected-stderr-pattern:
|
||||
/.*continue.*/
|
||||
---
|
||||
|
||||
|
||||
name: continue-4
|
||||
description:
|
||||
What if continue N used when only N-1 loops
|
||||
(ksh88,ksh93 don't print error messages here)
|
||||
stdin:
|
||||
for i in a b c; do echo $i; continue 2; echo bad-$i; done
|
||||
echo end
|
||||
expected-stdout:
|
||||
a
|
||||
b
|
||||
c
|
||||
end
|
||||
expected-stderr-pattern:
|
||||
/.*continue.*/
|
||||
---
|
||||
|
||||
|
||||
name: continue-5
|
||||
description:
|
||||
Error if continue argument isn't a number
|
||||
stdin:
|
||||
for i in a b c; do echo $i; continue abc; echo more-$i; done
|
||||
echo end
|
||||
expected-stdout:
|
||||
a
|
||||
expected-exit: e != 0
|
||||
expected-stderr-pattern:
|
||||
/.*continue.*/
|
||||
---
|
||||
|
||||
|
162
tests/cdhist.t
Normal file
162
tests/cdhist.t
Normal file
@@ -0,0 +1,162 @@
|
||||
name: cd-history
|
||||
description:
|
||||
Test someone's CD history package (uses arrays)
|
||||
# Fails on OS/2, since directory names are prepended with drive letter.
|
||||
category: !os:os2
|
||||
stdin:
|
||||
# go to known place before doing anything
|
||||
cd /
|
||||
|
||||
alias cd=_cd
|
||||
function _cd
|
||||
{
|
||||
typeset -i cdlen i
|
||||
typeset t
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
set -- $HOME
|
||||
fi
|
||||
|
||||
if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
|
||||
then
|
||||
typeset CDHIST
|
||||
i=-1
|
||||
while read -r t # read directory history file
|
||||
do
|
||||
CDHIST[i=i+1]=$t
|
||||
done <$CDHISTFILE
|
||||
fi
|
||||
|
||||
if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
|
||||
then
|
||||
_cdins # insert $PWD into cd history
|
||||
fi
|
||||
|
||||
cdlen=${#CDHIST[*]} # number of elements in history
|
||||
|
||||
case "$@" in
|
||||
-) # cd to new dir
|
||||
if [ "$OLDPWD" = "" ] && ((cdlen>1))
|
||||
then
|
||||
'print' ${CDHIST[1]}
|
||||
'cd' ${CDHIST[1]}
|
||||
_pwd
|
||||
else
|
||||
'cd' $@
|
||||
_pwd
|
||||
fi
|
||||
;;
|
||||
-l) # print directory list
|
||||
typeset -R3 num
|
||||
((i=cdlen))
|
||||
while (((i=i-1)>=0))
|
||||
do
|
||||
num=$i
|
||||
'print' "$num ${CDHIST[i]}"
|
||||
done
|
||||
return
|
||||
;;
|
||||
-[0-9]|-[0-9][0-9]) # cd to dir in list
|
||||
if (((i=${1#-})<cdlen))
|
||||
then
|
||||
'print' ${CDHIST[i]}
|
||||
'cd' ${CDHIST[i]}
|
||||
_pwd
|
||||
else
|
||||
'cd' $@
|
||||
_pwd
|
||||
fi
|
||||
;;
|
||||
-*) # cd to matched dir in list
|
||||
t=${1#-}
|
||||
i=1
|
||||
while ((i<cdlen))
|
||||
do
|
||||
case ${CDHIST[i]} in
|
||||
*$t*)
|
||||
'print' ${CDHIST[i]}
|
||||
'cd' ${CDHIST[i]}
|
||||
_pwd
|
||||
break
|
||||
;;
|
||||
esac
|
||||
((i=i+1))
|
||||
done
|
||||
if ((i>=cdlen))
|
||||
then
|
||||
'cd' $@
|
||||
_pwd
|
||||
fi
|
||||
;;
|
||||
*) # cd to new dir
|
||||
'cd' $@
|
||||
_pwd
|
||||
;;
|
||||
esac
|
||||
|
||||
_cdins # insert $PWD into cd history
|
||||
|
||||
if [ "$CDHISTFILE" ]
|
||||
then
|
||||
cdlen=${#CDHIST[*]} # number of elements in history
|
||||
|
||||
i=0
|
||||
while ((i<cdlen))
|
||||
do
|
||||
'print' -r ${CDHIST[i]} # update directory history
|
||||
((i=i+1))
|
||||
done >$CDHISTFILE
|
||||
fi
|
||||
}
|
||||
|
||||
function _cdins # insert $PWD into cd history
|
||||
{ # meant to be called only by _cd
|
||||
typeset -i i
|
||||
|
||||
((i=0))
|
||||
while ((i<${#CDHIST[*]})) # see if dir is already in list
|
||||
do
|
||||
if [ "${CDHIST[$i]}" = "$PWD" ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
((i=i+1))
|
||||
done
|
||||
|
||||
if ((i>22)) # limit max size of list
|
||||
then
|
||||
i=22
|
||||
fi
|
||||
|
||||
while (((i=i-1)>=0)) # bump old dirs in list
|
||||
do
|
||||
CDHIST[i+1]=${CDHIST[i]}
|
||||
done
|
||||
|
||||
CDHIST[0]=$PWD # insert new directory in list
|
||||
}
|
||||
|
||||
|
||||
function _pwd
|
||||
{
|
||||
if [ -n "$ECD" ]
|
||||
then
|
||||
pwd 1>&6
|
||||
fi
|
||||
}
|
||||
# Start of test
|
||||
cd /tmp
|
||||
cd /bin
|
||||
cd /etc
|
||||
cd -
|
||||
cd -2
|
||||
cd -l
|
||||
expected-stdout:
|
||||
/bin
|
||||
/tmp
|
||||
3 /
|
||||
2 /etc
|
||||
1 /bin
|
||||
0 /tmp
|
||||
---
|
145
tests/eglob.t
Normal file
145
tests/eglob.t
Normal file
@@ -0,0 +1,145 @@
|
||||
name: eglob-bad-1
|
||||
description:
|
||||
Check that globbing isn't done when glob has syntax error
|
||||
file-setup: file 644 "abcx"
|
||||
file-setup: file 644 "abcz"
|
||||
file-setup: file 644 "bbc"
|
||||
stdin:
|
||||
echo !([*)*
|
||||
echo +(a|b[)*
|
||||
expected-stdout:
|
||||
!([*)*
|
||||
+(a|b[)*
|
||||
---
|
||||
|
||||
name: eglob-bad-2
|
||||
description:
|
||||
Check that globbing isn't done when glob has syntax error
|
||||
(at&t ksh fails this test)
|
||||
file-setup: file 644 "abcx"
|
||||
file-setup: file 644 "abcz"
|
||||
file-setup: file 644 "bbc"
|
||||
stdin:
|
||||
echo [a*(]*)z
|
||||
expected-stdout:
|
||||
[a*(]*)z
|
||||
---
|
||||
|
||||
name: eglob-infinite-plus
|
||||
description:
|
||||
Check that shell doesn't go into infinite loop expanding +(...)
|
||||
expressions.
|
||||
file-setup: file 644 "abc"
|
||||
time-limit: 3
|
||||
stdin:
|
||||
echo +()c
|
||||
echo +()x
|
||||
echo +(*)c
|
||||
echo +(*)x
|
||||
expected-stdout:
|
||||
+()c
|
||||
+()x
|
||||
abc
|
||||
+(*)x
|
||||
---
|
||||
|
||||
name: eglob-subst-1
|
||||
description:
|
||||
Check that eglobbing isn't done on substitution results
|
||||
file-setup: file 644 "abc"
|
||||
stdin:
|
||||
x='@(*)'
|
||||
echo $x
|
||||
expected-stdout:
|
||||
@(*)
|
||||
---
|
||||
|
||||
name: eglob-nomatch-1
|
||||
description:
|
||||
Check that the pattern doesn't match
|
||||
stdin:
|
||||
echo 1: no-file+(a|b)stuff
|
||||
echo 2: no-file+(a*(c)|b)stuff
|
||||
echo 3: no-file+((((c)))|b)stuff
|
||||
expected-stdout:
|
||||
1: no-file+(a|b)stuff
|
||||
2: no-file+(a*(c)|b)stuff
|
||||
3: no-file+((((c)))|b)stuff
|
||||
---
|
||||
|
||||
name: eglob-match-1
|
||||
description:
|
||||
Check that the pattern matches correctly
|
||||
file-setup: file 644 "abd"
|
||||
file-setup: file 644 "acd"
|
||||
file-setup: file 644 "abac"
|
||||
stdin:
|
||||
echo 1: a+(b|c)d
|
||||
echo 2: a!(@(b|B))d
|
||||
echo 3: *(a(b|c)) # (...|...) can be used within X(..)
|
||||
echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
|
||||
expected-stdout:
|
||||
1: abd acd
|
||||
2: acd
|
||||
3: abac
|
||||
4: abd
|
||||
---
|
||||
|
||||
name: eglob-case-1
|
||||
description:
|
||||
Simple negation tests
|
||||
stdin:
|
||||
case foo in !(foo|bar)) echo yes;; *) echo no;; esac
|
||||
case bar in !(foo|bar)) echo yes;; *) echo no;; esac
|
||||
expected-stdout:
|
||||
no
|
||||
no
|
||||
---
|
||||
|
||||
name: eglob-case-2
|
||||
description:
|
||||
Simple kleene tests
|
||||
stdin:
|
||||
case foo in *(a|b[)) echo yes;; *) echo no;; esac
|
||||
case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
|
||||
case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
|
||||
expected-stdout:
|
||||
no
|
||||
yes
|
||||
yes
|
||||
---
|
||||
|
||||
name: eglob-trim-1
|
||||
description:
|
||||
Eglobing in trim expressions...
|
||||
(at&t ksh fails this - docs say # matches shortest string, ## matches
|
||||
longest...)
|
||||
stdin:
|
||||
x=abcdef
|
||||
echo 1: ${x#a|abc}
|
||||
echo 2: ${x##a|abc}
|
||||
echo 3: ${x%def|f}
|
||||
echo 4: ${x%%f|def}
|
||||
expected-stdout:
|
||||
1: bcdef
|
||||
2: def
|
||||
3: abcde
|
||||
4: abc
|
||||
---
|
||||
|
||||
name: eglob-trim-2
|
||||
description:
|
||||
Check eglobing works in trims...
|
||||
stdin:
|
||||
x=abcdef
|
||||
echo 1: ${x#*(a|b)cd}
|
||||
echo 2: "${x#*(a|b)cd}"
|
||||
echo 3: ${x#"*(a|b)cd"}
|
||||
echo 4: ${x#a(b|c)}
|
||||
expected-stdout:
|
||||
1: ef
|
||||
2: ef
|
||||
3: abcdef
|
||||
4: cdef
|
||||
---
|
||||
|
99
tests/glob.t
Normal file
99
tests/glob.t
Normal file
@@ -0,0 +1,99 @@
|
||||
name: glob-bad-1
|
||||
description:
|
||||
Check that globbing isn't done when glob has syntax error
|
||||
file-setup: dir 755 "[x"
|
||||
file-setup: file 644 "[x/foo"
|
||||
stdin:
|
||||
echo [*
|
||||
echo *[x
|
||||
echo [x/*
|
||||
expected-stdout:
|
||||
[*
|
||||
*[x
|
||||
[x/foo
|
||||
---
|
||||
|
||||
name: glob-bad-2
|
||||
description:
|
||||
Check that symbolic links aren't stat()'d
|
||||
category: !os:os2
|
||||
file-setup: dir 755 "dir"
|
||||
file-setup: symlink 644 "dir/abc"
|
||||
non-existant-file
|
||||
stdin:
|
||||
echo d*/*
|
||||
echo d*/abc
|
||||
expected-stdout:
|
||||
dir/abc
|
||||
dir/abc
|
||||
---
|
||||
|
||||
name: glob-range-1
|
||||
description:
|
||||
Test range matching
|
||||
file-setup: file 644 ".bc"
|
||||
file-setup: file 644 "abc"
|
||||
file-setup: file 644 "bbc"
|
||||
file-setup: file 644 "cbc"
|
||||
file-setup: file 644 "-bc"
|
||||
stdin:
|
||||
echo [ab-]*
|
||||
echo [-ab]*
|
||||
echo [!-ab]*
|
||||
echo [!ab]*
|
||||
echo []ab]*
|
||||
expected-stdout:
|
||||
-bc abc bbc
|
||||
-bc abc bbc
|
||||
cbc
|
||||
-bc cbc
|
||||
abc bbc
|
||||
---
|
||||
|
||||
name: glob-range-2
|
||||
description:
|
||||
Test range matching
|
||||
(at&t ksh fails this; POSIX says invalid)
|
||||
file-setup: file 644 "abc"
|
||||
stdin:
|
||||
echo [a--]*
|
||||
expected-stdout:
|
||||
[a--]*
|
||||
---
|
||||
|
||||
name: glob-range-3
|
||||
description:
|
||||
Check that globbing matches the right things...
|
||||
file-setup: file 644 "a<>c"
|
||||
stdin:
|
||||
echo a[<EFBFBD>-<EFBFBD>]*
|
||||
expected-stdout:
|
||||
a<EFBFBD>c
|
||||
---
|
||||
|
||||
name: glob-range-4
|
||||
description:
|
||||
Results unspecified according to POSIX
|
||||
file-setup: file 644 ".bc"
|
||||
stdin:
|
||||
echo [a.]*
|
||||
expected-stdout:
|
||||
[a.]*
|
||||
---
|
||||
|
||||
name: glob-range-5
|
||||
description:
|
||||
Results unspecified according to POSIX
|
||||
(at&t ksh treats this like [a-cc-e]*)
|
||||
file-setup: file 644 "abc"
|
||||
file-setup: file 644 "bbc"
|
||||
file-setup: file 644 "cbc"
|
||||
file-setup: file 644 "dbc"
|
||||
file-setup: file 644 "ebc"
|
||||
file-setup: file 644 "-bc"
|
||||
stdin:
|
||||
echo [a-c-e]*
|
||||
expected-stdout:
|
||||
-bc abc bbc cbc ebc
|
||||
---
|
||||
|
331
tests/heredoc.t
Normal file
331
tests/heredoc.t
Normal file
@@ -0,0 +1,331 @@
|
||||
name: heredoc-1
|
||||
description:
|
||||
Check ordering/content of redundent here documents.
|
||||
stdin:
|
||||
cat << EOF1 << EOF2
|
||||
hi
|
||||
EOF1
|
||||
there
|
||||
EOF2
|
||||
expected-stdout:
|
||||
there
|
||||
---
|
||||
|
||||
name: heredoc-2
|
||||
description:
|
||||
Check quoted here-doc is protected.
|
||||
stdin:
|
||||
a=foo
|
||||
cat << 'EOF'
|
||||
hi\
|
||||
there$a
|
||||
stuff
|
||||
EO\
|
||||
F
|
||||
EOF
|
||||
expected-stdout:
|
||||
hi\
|
||||
there$a
|
||||
stuff
|
||||
EO\
|
||||
F
|
||||
---
|
||||
|
||||
name: heredoc-3
|
||||
description:
|
||||
Check that newline isn't needed after heredoc-delimiter marker.
|
||||
stdin: !
|
||||
cat << EOF
|
||||
hi
|
||||
there
|
||||
EOF
|
||||
expected-stdout:
|
||||
hi
|
||||
there
|
||||
---
|
||||
|
||||
name: heredoc-4
|
||||
description:
|
||||
Check that an error occurs if the heredoc-delimiter is missing.
|
||||
stdin: !
|
||||
cat << EOF
|
||||
hi
|
||||
there
|
||||
expected-exit: e > 0
|
||||
expected-stderr-pattern: /.*/
|
||||
---
|
||||
|
||||
name: heredoc-5
|
||||
description:
|
||||
Check that backslash quotes a $, ` and \ and kills a \newline
|
||||
stdin:
|
||||
a=BAD
|
||||
b=ok
|
||||
cat << EOF
|
||||
h\${a}i
|
||||
h\\${b}i
|
||||
th\`echo not-run\`ere
|
||||
th\\`echo is-run`ere
|
||||
fol\\ks
|
||||
more\\
|
||||
last \
|
||||
line
|
||||
EOF
|
||||
expected-stdout:
|
||||
h${a}i
|
||||
h\oki
|
||||
th`echo not-run`ere
|
||||
th\is-runere
|
||||
fol\ks
|
||||
more\
|
||||
last line
|
||||
---
|
||||
|
||||
name: heredoc-6
|
||||
description:
|
||||
Check that \newline in initial here-delim word doesn't imply
|
||||
a quoted here-doc.
|
||||
stdin:
|
||||
a=i
|
||||
cat << EO\
|
||||
F
|
||||
h$a
|
||||
there
|
||||
EOF
|
||||
expected-stdout:
|
||||
hi
|
||||
there
|
||||
---
|
||||
|
||||
name: heredoc-7
|
||||
description:
|
||||
Check that double quoted $ expressions in here delimiters are
|
||||
not expanded and match the delimiter.
|
||||
POSIX says only quote removal is applied to the delimiter.
|
||||
stdin:
|
||||
a=b
|
||||
cat << "E$a"
|
||||
hi
|
||||
h$a
|
||||
hb
|
||||
E$a
|
||||
echo done
|
||||
expected-stdout:
|
||||
hi
|
||||
h$a
|
||||
hb
|
||||
done
|
||||
---
|
||||
|
||||
name: heredoc-8
|
||||
description:
|
||||
Check that double quoted escaped $ expressions in here
|
||||
delimiters are not expanded and match the delimiter.
|
||||
POSIX says only quote removal is applied to the delimiter
|
||||
(\ counts as a quote).
|
||||
stdin:
|
||||
a=b
|
||||
cat << "E\$a"
|
||||
hi
|
||||
h$a
|
||||
h\$a
|
||||
hb
|
||||
h\b
|
||||
E$a
|
||||
echo done
|
||||
expected-stdout:
|
||||
hi
|
||||
h$a
|
||||
h\$a
|
||||
hb
|
||||
h\b
|
||||
done
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-1
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Heredoc in simple command.
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
cat <<- EOF
|
||||
hi
|
||||
EOF
|
||||
for i in a b ; do
|
||||
cat <<- EOF
|
||||
more
|
||||
EOF
|
||||
done
|
||||
' &
|
||||
sleep 1
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
hi
|
||||
more
|
||||
more
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-2
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Heredoc in function, multiple calls to function.
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
foo() {
|
||||
cat <<- EOF
|
||||
hi
|
||||
EOF
|
||||
}
|
||||
foo
|
||||
foo
|
||||
' &
|
||||
sleep 1
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
hi
|
||||
hi
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-3
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Heredoc in function in loop, multiple calls to function.
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
foo() {
|
||||
cat <<- EOF
|
||||
hi
|
||||
EOF
|
||||
}
|
||||
for i in a b; do
|
||||
foo
|
||||
foo() {
|
||||
cat <<- EOF
|
||||
folks $i
|
||||
EOF
|
||||
}
|
||||
done
|
||||
foo
|
||||
' &
|
||||
sleep 1
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
hi
|
||||
folks b
|
||||
folks b
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-4
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Backgrounded simple command with here doc
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
cat <<- EOF &
|
||||
hi
|
||||
EOF
|
||||
' &
|
||||
sleep 1
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
hi
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-5
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Backgrounded subshell command with here doc
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
(
|
||||
sleep 1 # so parent exits
|
||||
echo A
|
||||
cat <<- EOF
|
||||
hi
|
||||
EOF
|
||||
echo B
|
||||
) &
|
||||
' &
|
||||
sleep 2
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
A
|
||||
hi
|
||||
B
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-6
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Heredoc in pipeline.
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
cat <<- EOF | sed "s/hi/HI/"
|
||||
hi
|
||||
EOF
|
||||
' &
|
||||
sleep 1
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
HI
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-7
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Heredoc in backgrounded pipeline.
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
eval '
|
||||
cat <<- EOF | sed 's/hi/HI/' &
|
||||
hi
|
||||
EOF
|
||||
' &
|
||||
sleep 1
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
HI
|
||||
Left overs: *
|
||||
---
|
||||
|
||||
name: heredoc-tmpfile-8
|
||||
description:
|
||||
Check that heredoc temp files aren't removed too soon or too late.
|
||||
Heredoc in function, backgrounded call to function.
|
||||
stdin:
|
||||
TMPDIR=$PWD
|
||||
# Background eval so main shell doesn't do parsing
|
||||
eval '
|
||||
foo() {
|
||||
cat <<- EOF
|
||||
hi
|
||||
EOF
|
||||
}
|
||||
foo
|
||||
# sleep so eval can die
|
||||
(sleep 1; foo) &
|
||||
(sleep 1; foo) &
|
||||
foo
|
||||
' &
|
||||
sleep 2
|
||||
echo Left overs: *
|
||||
expected-stdout:
|
||||
hi
|
||||
hi
|
||||
hi
|
||||
hi
|
||||
Left overs: *
|
||||
---
|
||||
|
559
tests/history.t
Normal file
559
tests/history.t
Normal file
@@ -0,0 +1,559 @@
|
||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||
|
||||
# Not tested yet:
|
||||
# - commands in history file are not numbered negatively
|
||||
# (and a few hundred other things)
|
||||
|
||||
name: history-basic
|
||||
description:
|
||||
See if we can test history at all
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo hi
|
||||
fc -l
|
||||
expected-stdout:
|
||||
hi
|
||||
1 echo hi
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-e-minus-1
|
||||
description:
|
||||
Check if more recent command is executed
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo hi
|
||||
echo there
|
||||
fc -e -
|
||||
expected-stdout:
|
||||
hi
|
||||
there
|
||||
there
|
||||
expected-stderr-pattern:
|
||||
/^X*echo there\nX*$/
|
||||
---
|
||||
|
||||
name: history-e-minus-2
|
||||
description:
|
||||
Check that repeated command is printed before command
|
||||
is re-executed.
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
exec 2>&1
|
||||
echo hi
|
||||
echo there
|
||||
fc -e -
|
||||
expected-stdout-pattern:
|
||||
/X*hi\nX*there\nX*echo there\nthere\nX*/
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-e-minus-3
|
||||
description:
|
||||
fc -e - fails when there is no history
|
||||
(ksh93 has a bug that causes this to fail)
|
||||
(ksh88 loops on this)
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
fc -e -
|
||||
echo ok
|
||||
expected-stdout:
|
||||
ok
|
||||
expected-stderr-pattern:
|
||||
/^X*.*:.*history.*\nX*$/
|
||||
---
|
||||
|
||||
name: history-e-minus-4
|
||||
description:
|
||||
Check if "fc -e -" command output goes to stdout.
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc
|
||||
fc -e - | (read x; echo "A $x")
|
||||
echo ok
|
||||
expected-stdout:
|
||||
abc
|
||||
A abc
|
||||
ok
|
||||
expected-stderr-pattern:
|
||||
/^X*echo abc\nX*/
|
||||
---
|
||||
|
||||
name: history-e-minus-5
|
||||
description:
|
||||
fc is replaced in history by new command.
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
echo ghi jkl
|
||||
fc -e - echo
|
||||
fc -l 2 4
|
||||
expected-stdout:
|
||||
abc def
|
||||
ghi jkl
|
||||
ghi jkl
|
||||
2 echo ghi jkl
|
||||
3 echo ghi jkl
|
||||
4 fc -l 2 4
|
||||
expected-stderr-pattern:
|
||||
/^X*echo ghi jkl\nX*$/
|
||||
---
|
||||
|
||||
name: history-list-1
|
||||
description:
|
||||
List lists correct range
|
||||
(ksh88 fails 'cause it lists the fc command)
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
fc -l -- -2
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
2 echo line 2
|
||||
3 echo line 3
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-2
|
||||
description:
|
||||
Lists oldest history if given pre-historic number
|
||||
(ksh93 has a bug that causes this to fail)
|
||||
(ksh88 fails 'cause it lists the fc command)
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
fc -l -- -40
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
1 echo line 1
|
||||
2 echo line 2
|
||||
3 echo line 3
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-3
|
||||
description:
|
||||
Can give number `options' to fc
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
fc -l -3 -2
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
2 echo line 2
|
||||
3 echo line 3
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-4
|
||||
description:
|
||||
-1 refers to previous command
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
fc -l -1 -1
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
4 echo line 4
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-5
|
||||
description:
|
||||
List command stays in history
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
fc -l -1 -1
|
||||
fc -l -2 -1
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
4 echo line 4
|
||||
4 echo line 4
|
||||
5 fc -l -1 -1
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-6
|
||||
description:
|
||||
HISTSIZE limits about of history kept.
|
||||
(ksh88 fails 'cause it lists the fc command)
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
echo line 5
|
||||
fc -l
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
4 echo line 4
|
||||
5 echo line 5
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-7
|
||||
description:
|
||||
fc allows too old/new errors in range specification
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
echo line 5
|
||||
fc -l 1 30
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
4 echo line 4
|
||||
5 echo line 5
|
||||
6 fc -l 1 30
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-r-1
|
||||
description:
|
||||
test -r flag in history
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
echo line 5
|
||||
fc -l -r 2 4
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
4 echo line 4
|
||||
3 echo line 3
|
||||
2 echo line 2
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-r-2
|
||||
description:
|
||||
If first is newer than last, -r is implied.
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
echo line 5
|
||||
fc -l 4 2
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
4 echo line 4
|
||||
3 echo line 3
|
||||
2 echo line 2
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-list-r-3
|
||||
description:
|
||||
If first is newer than last, -r is cancelled.
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2
|
||||
echo line 3
|
||||
echo line 4
|
||||
echo line 5
|
||||
fc -l -r 4 2
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
2 echo line 2
|
||||
3 echo line 3
|
||||
4 echo line 4
|
||||
expected-stderr-pattern:
|
||||
/^X*$/
|
||||
---
|
||||
|
||||
name: history-subst-1
|
||||
description:
|
||||
Basic substitution
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
echo ghi jkl
|
||||
fc -e - abc=AB 'echo a'
|
||||
expected-stdout:
|
||||
abc def
|
||||
ghi jkl
|
||||
AB def
|
||||
expected-stderr-pattern:
|
||||
/^X*echo AB def\nX*$/
|
||||
---
|
||||
|
||||
name: history-subst-2
|
||||
description:
|
||||
Does subst find previous command?
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
echo ghi jkl
|
||||
fc -e - jkl=XYZQRT 'echo g'
|
||||
expected-stdout:
|
||||
abc def
|
||||
ghi jkl
|
||||
ghi XYZQRT
|
||||
expected-stderr-pattern:
|
||||
/^X*echo ghi XYZQRT\nX*$/
|
||||
---
|
||||
|
||||
name: history-subst-3
|
||||
description:
|
||||
Does subst find previous command when no arguments given
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
echo ghi jkl
|
||||
fc -e - jkl=XYZQRT
|
||||
expected-stdout:
|
||||
abc def
|
||||
ghi jkl
|
||||
ghi XYZQRT
|
||||
expected-stderr-pattern:
|
||||
/^X*echo ghi XYZQRT\nX*$/
|
||||
---
|
||||
|
||||
name: history-subst-4
|
||||
description:
|
||||
Global substitutions work
|
||||
(ksh88 and ksh93 do not have -g option)
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def asjj sadjhasdjh asdjhasd
|
||||
fc -e - -g a=FooBAR
|
||||
expected-stdout:
|
||||
abc def asjj sadjhasdjh asdjhasd
|
||||
FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
|
||||
expected-stderr-pattern:
|
||||
/^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
|
||||
---
|
||||
|
||||
name: history-subst-5
|
||||
description:
|
||||
Make sure searches don't find current (fc) command
|
||||
(ksh88/ksh93 don't have the ? prefix thing so they fail this test)
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
echo ghi jkl
|
||||
fc -e - abc=AB \?abc
|
||||
expected-stdout:
|
||||
abc def
|
||||
ghi jkl
|
||||
AB def
|
||||
expected-stderr-pattern:
|
||||
/^X*echo AB def\nX*$/
|
||||
---
|
||||
|
||||
name: history-ed-1
|
||||
description:
|
||||
Basic (ed) editing works (assumes you have generic ed editor
|
||||
that prints no prompts).
|
||||
# No ed on os/2 (yet?).
|
||||
category: !os:os2
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
fc echo
|
||||
s/abc/FOOBAR/
|
||||
w
|
||||
q
|
||||
expected-stdout:
|
||||
abc def
|
||||
13
|
||||
16
|
||||
FOOBAR def
|
||||
expected-stderr-pattern:
|
||||
/^X*echo FOOBAR def\nX*$/
|
||||
---
|
||||
|
||||
name: history-ed-2
|
||||
description:
|
||||
Correct command is edited when number given
|
||||
category: !os:os2
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo line 1
|
||||
echo line 2 is here
|
||||
echo line 3
|
||||
echo line 4
|
||||
fc 2
|
||||
s/is here/is changed/
|
||||
w
|
||||
q
|
||||
expected-stdout:
|
||||
line 1
|
||||
line 2 is here
|
||||
line 3
|
||||
line 4
|
||||
20
|
||||
23
|
||||
line 2 is changed
|
||||
expected-stderr-pattern:
|
||||
/^X*echo line 2 is changed\nX*$/
|
||||
---
|
||||
|
||||
name: history-ed-3
|
||||
description:
|
||||
Newly created multi line commands show up as single command
|
||||
in history.
|
||||
(NOTE: will fail if using COMPLEX HISTORY compile time option)
|
||||
(ksh88 fails 'cause it lists the fc command)
|
||||
category: !os:os2
|
||||
arguments: !-i!
|
||||
env-setup: !ENV=./Env!HISTFILE=hist.file!
|
||||
file-setup: file 644 "Env"
|
||||
PS1=X
|
||||
stdin:
|
||||
echo abc def
|
||||
fc echo
|
||||
s/abc/FOOBAR/
|
||||
$a
|
||||
echo a new line
|
||||
.
|
||||
w
|
||||
q
|
||||
fc -l
|
||||
expected-stdout:
|
||||
abc def
|
||||
13
|
||||
32
|
||||
FOOBAR def
|
||||
a new line
|
||||
1 echo abc def
|
||||
2 echo FOOBAR def
|
||||
echo a new line
|
||||
expected-stderr-pattern:
|
||||
/^X*echo FOOBAR def\necho a new line\nX*$/
|
||||
---
|
162
tests/ifs.t
Normal file
162
tests/ifs.t
Normal file
@@ -0,0 +1,162 @@
|
||||
name: IFS-space-1
|
||||
description:
|
||||
Simple test, default IFS
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
set -- A B C
|
||||
showargs 1 $*
|
||||
showargs 2 "$*"
|
||||
showargs 3 $@
|
||||
showargs 4 "$@"
|
||||
expected-stdout:
|
||||
<1> <A> <B> <C>
|
||||
<2> <A B C>
|
||||
<3> <A> <B> <C>
|
||||
<4> <A> <B> <C>
|
||||
---
|
||||
|
||||
name: IFS-colon-1
|
||||
description:
|
||||
Simple test, IFS=:
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS=:
|
||||
set -- A B C
|
||||
showargs 1 $*
|
||||
showargs 2 "$*"
|
||||
showargs 3 $@
|
||||
showargs 4 "$@"
|
||||
expected-stdout:
|
||||
<1> <A> <B> <C>
|
||||
<2> <A:B:C>
|
||||
<3> <A> <B> <C>
|
||||
<4> <A> <B> <C>
|
||||
---
|
||||
|
||||
name: IFS-null-1
|
||||
description:
|
||||
Simple test, IFS=""
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS=""
|
||||
set -- A B C
|
||||
showargs 1 $*
|
||||
showargs 2 "$*"
|
||||
showargs 3 $@
|
||||
showargs 4 "$@"
|
||||
expected-stdout:
|
||||
<1> <A B C>
|
||||
<2> <ABC>
|
||||
<3> <A B C>
|
||||
<4> <A B C>
|
||||
---
|
||||
|
||||
name: IFS-space-colon-1
|
||||
description:
|
||||
Simple test, IFS=<white-space>:
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS="IFS:"
|
||||
set --
|
||||
showargs 1 $*
|
||||
showargs 2 "$*"
|
||||
showargs 3 $@
|
||||
showargs 4 "$@"
|
||||
showargs 5 : "$@"
|
||||
expected-stdout:
|
||||
<1>
|
||||
<2> <>
|
||||
<3>
|
||||
<4>
|
||||
<5> <:>
|
||||
---
|
||||
|
||||
name: IFS-space-colon-2
|
||||
description:
|
||||
Simple test, IFS=<white-space>:
|
||||
At&t ksh fails this, POSIX says the test is correct.
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS="IFS:"
|
||||
set --
|
||||
showargs :"$@"
|
||||
expected-stdout:
|
||||
<:>
|
||||
---
|
||||
|
||||
name: IFS-space-colon-3
|
||||
description:
|
||||
Simple test, IFS=<white-space>:
|
||||
pdksh fails both of these tests
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS="IFS:"
|
||||
x=
|
||||
set --
|
||||
showargs "$x$@"
|
||||
showargs "$@$x"
|
||||
expected-fail: yes
|
||||
expected-stdout:
|
||||
<>
|
||||
<>
|
||||
---
|
||||
|
||||
name: IFS-space-colon-4
|
||||
description:
|
||||
Simple test, IFS=<white-space>:
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS="IFS:"
|
||||
set --
|
||||
showargs "$@$@"
|
||||
expected-stdout:
|
||||
|
||||
---
|
||||
|
||||
name: IFS-space-colon-5
|
||||
description:
|
||||
Simple test, IFS=<white-space>:
|
||||
Don't know what POSIX thinks of this. at&t ksh does not do this.
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS="IFS:"
|
||||
set --
|
||||
showargs "${@:-}"
|
||||
expected-stdout:
|
||||
<>
|
||||
---
|
||||
|
||||
name: IFS-subst-1
|
||||
description:
|
||||
Simple test, IFS=<white-space>:
|
||||
stdin:
|
||||
showargs() { for i; do echo -n " <$i>"; done; echo; }
|
||||
IFS="$IFS:"
|
||||
x=":b: :"
|
||||
echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
|
||||
echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
|
||||
showargs 3 $x
|
||||
showargs 4 :b::
|
||||
x="a:b:"
|
||||
echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
|
||||
showargs 6 $x
|
||||
x="a::c"
|
||||
echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
|
||||
showargs 8 $x
|
||||
echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
|
||||
showargs 10 ${FOO-`echo -n h:i`th:ere}
|
||||
showargs 11 "${FOO-`echo -n h:i`th:ere}"
|
||||
expected-stdout:
|
||||
1: [] [b] [] []
|
||||
2: [:b::]
|
||||
<3> <> <b> <> <>
|
||||
<4> <:b::>
|
||||
5: [a] [b] []
|
||||
<6> <a> <b> <>
|
||||
7: [a] [] [c]
|
||||
<8> <a> <> <c>
|
||||
9: [h] [ith] [ere]
|
||||
<10> <h> <ith> <ere>
|
||||
<11> <h:ith:ere>
|
||||
---
|
||||
|
218
tests/integer.t
Normal file
218
tests/integer.t
Normal file
@@ -0,0 +1,218 @@
|
||||
name: integer-base-err-1
|
||||
description:
|
||||
Can't have 0 base (causes shell to exit)
|
||||
expected-exit: e != 0
|
||||
stdin:
|
||||
typeset -i i
|
||||
i=3
|
||||
i=0#4
|
||||
echo $i
|
||||
expected-stderr-pattern:
|
||||
/^.*:.*0#4.*\n$/
|
||||
---
|
||||
|
||||
name: integer-base-err-2
|
||||
description:
|
||||
Can't have multiple bases in a `constant' (causes shell to exit)
|
||||
(ksh88 fails this test)
|
||||
expected-exit: e != 0
|
||||
stdin:
|
||||
typeset -i i
|
||||
i=3
|
||||
i=2#110#11
|
||||
echo $i
|
||||
expected-stderr-pattern:
|
||||
/^.*:.*2#110#11.*\n$/
|
||||
---
|
||||
|
||||
name: integer-base-err-3
|
||||
description:
|
||||
Syntax errors in expressions and effects on bases
|
||||
(interactive so errors don't cause exits)
|
||||
(ksh88 fails this test - shell exits, even with -i)
|
||||
arguments: !-i!
|
||||
stdin:
|
||||
PS1= # minimize prompt hassles
|
||||
typeset -i4 a=10
|
||||
typeset -i a=2+
|
||||
echo $a
|
||||
typeset -i4 a=10
|
||||
typeset -i2 a=2+
|
||||
echo $a
|
||||
expected-stderr-pattern:
|
||||
/^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
|
||||
expected-stdout:
|
||||
4#22
|
||||
4#22
|
||||
---
|
||||
|
||||
name: integer-base-err-4
|
||||
description:
|
||||
Are invalid digits (according to base) errors?
|
||||
(ksh93 fails this test)
|
||||
expected-exit: e != 0
|
||||
stdin:
|
||||
typeset -i i;
|
||||
i=3#4
|
||||
expected-stderr-pattern:
|
||||
/^([#\$] )?.*:.*3#4.*\n$/
|
||||
---
|
||||
|
||||
|
||||
name: integer-base-1
|
||||
description:
|
||||
Missing number after base is treated as 0.
|
||||
stdin:
|
||||
typeset -i i
|
||||
i=3
|
||||
i=2#
|
||||
echo $i
|
||||
expected-stdout:
|
||||
0
|
||||
---
|
||||
|
||||
name: integer-base-2
|
||||
description:
|
||||
Check `stickyness' of base in various situations
|
||||
stdin:
|
||||
typeset -i i=8
|
||||
echo $i
|
||||
echo ---------- A
|
||||
typeset -i4 j=8
|
||||
echo $j
|
||||
echo ---------- B
|
||||
typeset -i k=8
|
||||
typeset -i4 k=8
|
||||
echo $k
|
||||
echo ---------- C
|
||||
typeset -i4 l
|
||||
l=3#10
|
||||
echo $l
|
||||
echo ---------- D
|
||||
typeset -i m
|
||||
m=3#10
|
||||
echo $m
|
||||
echo ---------- E
|
||||
n=2#11
|
||||
typeset -i n
|
||||
echo $n
|
||||
n=10
|
||||
echo $n
|
||||
echo ---------- F
|
||||
typeset -i8 o=12
|
||||
typeset -i4 o
|
||||
echo $o
|
||||
echo ---------- G
|
||||
typeset -i p
|
||||
let p=8#12
|
||||
echo $p
|
||||
expected-stdout:
|
||||
8
|
||||
---------- A
|
||||
4#20
|
||||
---------- B
|
||||
4#20
|
||||
---------- C
|
||||
4#3
|
||||
---------- D
|
||||
3#10
|
||||
---------- E
|
||||
2#11
|
||||
2#1010
|
||||
---------- F
|
||||
4#30
|
||||
---------- G
|
||||
8#12
|
||||
---
|
||||
|
||||
name: integer-base-3
|
||||
description:
|
||||
More base parsing (hmm doesn't test much..)
|
||||
stdin:
|
||||
typeset -i aa
|
||||
aa=1+12#10+2
|
||||
echo $aa
|
||||
typeset -i bb
|
||||
bb=1+$aa
|
||||
echo $bb
|
||||
typeset -i bb
|
||||
bb=$aa
|
||||
echo $bb
|
||||
typeset -i cc
|
||||
cc=$aa
|
||||
echo $cc
|
||||
expected-stdout:
|
||||
15
|
||||
16
|
||||
15
|
||||
15
|
||||
---
|
||||
|
||||
name: integer-base-4
|
||||
description:
|
||||
Check that things not declared as integers are not made integers,
|
||||
also, check if base is not reset by -i with no arguments.
|
||||
(ksh93 fails - prints 10#20 - go figure)
|
||||
stdin:
|
||||
xx=20
|
||||
let xx=10
|
||||
typeset -i | grep '^xx='
|
||||
typeset -i4 a=10
|
||||
typeset -i a=20
|
||||
echo $a
|
||||
expected-stdout:
|
||||
4#110
|
||||
---
|
||||
|
||||
name: integer-base-5
|
||||
description:
|
||||
More base stuff
|
||||
stdin:
|
||||
typeset -i4 a=3#10
|
||||
echo $a
|
||||
echo --
|
||||
typeset -i j=3
|
||||
j=~3
|
||||
echo $j
|
||||
echo --
|
||||
typeset -i k=1
|
||||
x[k=k+1]=3
|
||||
echo $k
|
||||
echo --
|
||||
typeset -i l
|
||||
for l in 1 2+3 4; do echo $l; done
|
||||
expected-stdout:
|
||||
4#3
|
||||
--
|
||||
-4
|
||||
--
|
||||
2
|
||||
--
|
||||
1
|
||||
5
|
||||
4
|
||||
---
|
||||
|
||||
name: integer-base-6
|
||||
description:
|
||||
Even more base stuff
|
||||
(ksh93 fails this test - prints 0)
|
||||
stdin:
|
||||
typeset -i7 i
|
||||
i=
|
||||
echo $i
|
||||
expected-stdout:
|
||||
7#0
|
||||
---
|
||||
|
||||
name: integer-base-7
|
||||
description:
|
||||
Check that non-integer parameters don't get bases assigned
|
||||
stdin:
|
||||
echo $(( zz = 8#100 ))
|
||||
echo $zz
|
||||
expected-stdout:
|
||||
64
|
||||
64
|
||||
---
|
||||
|
111
tests/lineno.t
Normal file
111
tests/lineno.t
Normal file
@@ -0,0 +1,111 @@
|
||||
name: lineno-stdin
|
||||
description:
|
||||
See if $LINENO is updated and can be modified.
|
||||
stdin:
|
||||
echo A $LINENO
|
||||
echo B $LINENO
|
||||
LINENO=20
|
||||
echo C $LINENO
|
||||
expected-stdout:
|
||||
A 1
|
||||
B 2
|
||||
C 20
|
||||
---
|
||||
|
||||
name: lineno-inc
|
||||
description:
|
||||
See if $LINENO is set for .'d files.
|
||||
file-setup: file 644 "dotfile"
|
||||
echo dot A $LINENO
|
||||
echo dot B $LINENO
|
||||
LINENO=20
|
||||
echo dot C $LINENO
|
||||
stdin:
|
||||
echo A $LINENO
|
||||
echo B $LINENO
|
||||
. ./dotfile
|
||||
expected-stdout:
|
||||
A 1
|
||||
B 2
|
||||
dot A 1
|
||||
dot B 2
|
||||
dot C 20
|
||||
---
|
||||
|
||||
|
||||
name: lineno-func
|
||||
description:
|
||||
See if $LINENO is set for commands in a function.
|
||||
stdin:
|
||||
echo A $LINENO
|
||||
echo B $LINENO
|
||||
bar() {
|
||||
echo func A $LINENO
|
||||
echo func B $LINENO
|
||||
}
|
||||
bar
|
||||
echo C $LINENO
|
||||
expected-stdout:
|
||||
A 1
|
||||
B 2
|
||||
func A 4
|
||||
func B 5
|
||||
C 8
|
||||
---
|
||||
|
||||
name: lineno-unset
|
||||
description:
|
||||
See if unsetting LINENO makes it non-magic.
|
||||
file-setup: file 644 "dotfile"
|
||||
echo dot A $LINENO
|
||||
echo dot B $LINENO
|
||||
stdin:
|
||||
unset LINENO
|
||||
echo A $LINENO
|
||||
echo B $LINENO
|
||||
bar() {
|
||||
echo func A $LINENO
|
||||
echo func B $LINENO
|
||||
}
|
||||
bar
|
||||
. ./dotfile
|
||||
echo C $LINENO
|
||||
expected-stdout:
|
||||
A
|
||||
B
|
||||
func A
|
||||
func B
|
||||
dot A
|
||||
dot B
|
||||
C
|
||||
---
|
||||
|
||||
name: lineno-unset-use
|
||||
description:
|
||||
See if unsetting LINENO makes it non-magic even
|
||||
when it is re-used.
|
||||
file-setup: file 644 "dotfile"
|
||||
echo dot A $LINENO
|
||||
echo dot B $LINENO
|
||||
stdin:
|
||||
unset LINENO
|
||||
LINENO=3
|
||||
echo A $LINENO
|
||||
echo B $LINENO
|
||||
bar() {
|
||||
echo func A $LINENO
|
||||
echo func B $LINENO
|
||||
}
|
||||
bar
|
||||
. ./dotfile
|
||||
echo C $LINENO
|
||||
expected-stdout:
|
||||
A 3
|
||||
B 3
|
||||
func A 3
|
||||
func B 3
|
||||
dot A 3
|
||||
dot B 3
|
||||
C 3
|
||||
---
|
||||
|
58
tests/read.t
Normal file
58
tests/read.t
Normal file
@@ -0,0 +1,58 @@
|
||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||
|
||||
#
|
||||
# To test:
|
||||
# POSIX:
|
||||
# - if no -r, \ is escape character
|
||||
# - \newline disappear
|
||||
# - \<IFS> -> don't break here
|
||||
# - \<anything-else> -> <anything-else>
|
||||
# - if -r, backslash is not special
|
||||
# - if stdin is tty and shell interactive
|
||||
# - prompt for continuation if \newline (prompt to stderr)
|
||||
# - a here-document isn't terminated after newline ????
|
||||
# - remaining vars set to empty string (not null)
|
||||
# - check field splitting
|
||||
# - left over fields and their separators assigned to last var
|
||||
# - exit status is normally 0
|
||||
# - exit status is > 0 on eof
|
||||
# - exit status > 0 on error
|
||||
# - signals interrupt reads
|
||||
# extra:
|
||||
# - can't change read-only variables
|
||||
# - error if var name bogus
|
||||
# - set -o allexport effects read
|
||||
# ksh:
|
||||
# x check default variable: REPLY
|
||||
# - check -p, -s, -u options
|
||||
# - check var?prompt stuff
|
||||
# - "echo a b | read x y" sets x,y in parent shell (at&t)
|
||||
#
|
||||
name: read-IFS-1
|
||||
description:
|
||||
Simple test, default IFS
|
||||
stdin:
|
||||
echo "A B " > IN
|
||||
unset x y z
|
||||
read x y z < IN
|
||||
echo 1: "x[$x] y[$y] z[$z]"
|
||||
echo 1a: ${z-z not set}
|
||||
read x < IN
|
||||
echo 2: "x[$x]"
|
||||
expected-stdout:
|
||||
1: x[A] y[B] z[]
|
||||
1a:
|
||||
2: x[A B]
|
||||
---
|
||||
|
||||
name: read-ksh-1
|
||||
description:
|
||||
If no var specified, REPLY is used
|
||||
stdin:
|
||||
echo "abc" > IN
|
||||
read < IN
|
||||
echo "[$REPLY]";
|
||||
expected-stdout:
|
||||
[abc]
|
||||
---
|
||||
|
1093
tests/regress.t
Normal file
1093
tests/regress.t
Normal file
File diff suppressed because it is too large
Load Diff
10
tests/syntax.t
Normal file
10
tests/syntax.t
Normal file
@@ -0,0 +1,10 @@
|
||||
name: syntax-1
|
||||
description:
|
||||
Check that lone ampersand is a syntax error
|
||||
stdin:
|
||||
&
|
||||
expected-exit: e != 0
|
||||
expected-stderr-pattern:
|
||||
/syntax error/
|
||||
---
|
||||
|
30
tests/th-sh
Normal file
30
tests/th-sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# $OpenBSD: th-sh,v 1.2 2001/01/28 23:04:57 niklas Exp $
|
||||
|
||||
|
||||
#
|
||||
# Simple script to find perl and run it
|
||||
#
|
||||
|
||||
# Avoid common problems with ENV (though perl shouldn't let it through)
|
||||
# (can you believe some shells don't have an unset???)
|
||||
unset ENV
|
||||
|
||||
x=x
|
||||
[ -x /bin/sh ] 2> /dev/null || x=f
|
||||
|
||||
IFS=:$IFS
|
||||
perl=
|
||||
for i in $PATH; do
|
||||
[ X"$i" = X ] && i=.
|
||||
for j in perl perl4 perl5 ; do
|
||||
[ -$x "$i/$j" ] && perl=$i/$j && break 2
|
||||
done
|
||||
done
|
||||
|
||||
[ X"$perl" = X ] && {
|
||||
echo "$0: can't find perl - bye\n" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
exec $perl "$@"
|
30
tests/th.sh
Normal file
30
tests/th.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# $OpenBSD: th.sh,v 1.4 2001/01/28 23:04:57 niklas Exp $
|
||||
|
||||
|
||||
#
|
||||
# Simple script to find perl and run it
|
||||
#
|
||||
|
||||
# Avoid common problems with ENV (though perl shouldn't let it through)
|
||||
# (can you believe some shells don't have an unset???)
|
||||
unset ENV
|
||||
|
||||
x=x
|
||||
[ -x /bin/sh ] 2> /dev/null || x=f
|
||||
|
||||
IFS=:$IFS
|
||||
perl=
|
||||
for i in $PATH; do
|
||||
[ X"$i" = X ] && i=.
|
||||
for j in perl perl4 perl5 ; do
|
||||
[ -$x "$i/$j" ] && perl=$i/$j && break 2
|
||||
done
|
||||
done
|
||||
|
||||
[ X"$perl" = X ] && {
|
||||
echo "$0: can't find perl - bye\n" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
exec $perl "$@"
|
99
tests/unclass1.t
Normal file
99
tests/unclass1.t
Normal file
@@ -0,0 +1,99 @@
|
||||
name: xxx-quoted-newline-1
|
||||
description:
|
||||
Check that \<newline> works inside of ${}
|
||||
stdin:
|
||||
abc=2
|
||||
echo ${ab\
|
||||
c}
|
||||
expected-stdout:
|
||||
2
|
||||
---
|
||||
|
||||
name: xxx-quoted-newline-2
|
||||
description:
|
||||
Check that \<newline> works at the start of a here document
|
||||
stdin:
|
||||
cat << EO\
|
||||
F
|
||||
hi
|
||||
EOF
|
||||
expected-stdout:
|
||||
hi
|
||||
---
|
||||
|
||||
name: xxx-quoted-newline-3
|
||||
description:
|
||||
Check that \<newline> works at the end of a here document
|
||||
stdin:
|
||||
cat << EOF
|
||||
hi
|
||||
EO\
|
||||
F
|
||||
expected-stdout:
|
||||
hi
|
||||
---
|
||||
|
||||
name: xxx-multi-assignment-cmd
|
||||
description:
|
||||
Check that assignments in a command affect subsequent assignments
|
||||
in the same command
|
||||
stdin:
|
||||
FOO=abc
|
||||
FOO=123 BAR=$FOO
|
||||
echo $BAR
|
||||
expected-stdout:
|
||||
123
|
||||
---
|
||||
|
||||
name: xxx-exec-environment-1
|
||||
description:
|
||||
Check to see if exec sets it's environment correctly
|
||||
stdin:
|
||||
FOO=bar exec env
|
||||
expected-stdout-pattern:
|
||||
/(^|.*\n)FOO=bar\n/
|
||||
---
|
||||
|
||||
name: xxx-exec-environment-2
|
||||
description:
|
||||
Check to make sure exec doesn't change environment if a program
|
||||
isn't exec-ed
|
||||
# Under os/2, _emx_sig environment variable changes.
|
||||
category: !os:os2
|
||||
stdin:
|
||||
env > bar1
|
||||
FOO=bar exec; env > bar2
|
||||
cmp -s bar1 bar2
|
||||
---
|
||||
|
||||
name: xxx-what-do-you-call-this-1
|
||||
stdin:
|
||||
echo "${foo:-"a"}*"
|
||||
expected-stdout:
|
||||
a*
|
||||
---
|
||||
|
||||
name: xxx-prefix-strip-1
|
||||
stdin:
|
||||
foo='a cdef'
|
||||
echo ${foo#a c}
|
||||
expected-stdout:
|
||||
def
|
||||
---
|
||||
|
||||
name: xxx-prefix-strip-2
|
||||
stdin:
|
||||
set a c
|
||||
x='a cdef'
|
||||
echo ${x#$*}
|
||||
expected-stdout:
|
||||
def
|
||||
---
|
||||
|
||||
name: xxx-variable-syntax-1
|
||||
stdin:
|
||||
echo ${:}
|
||||
expected-stderr-pattern:
|
||||
/bad substitution/
|
||||
expected-exit: 1
|
||||
---
|
163
tests/unclass2.t
Normal file
163
tests/unclass2.t
Normal file
@@ -0,0 +1,163 @@
|
||||
name: xxx-subsitution-eval-order
|
||||
description:
|
||||
Check order of evaluation of expressions
|
||||
stdin:
|
||||
i=1 x= y=
|
||||
set -A A abc def GHI j G k
|
||||
echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
|
||||
echo $x $y
|
||||
expected-stdout:
|
||||
HI
|
||||
2 4
|
||||
---
|
||||
|
||||
name: xxx-set-option-1
|
||||
description:
|
||||
Check option parsing in set
|
||||
stdin:
|
||||
set -vsA foo -- A 1 3 2
|
||||
echo ${foo[*]}
|
||||
expected-stderr:
|
||||
echo ${foo[*]}
|
||||
expected-stdout:
|
||||
1 2 3 A
|
||||
---
|
||||
|
||||
name: xxx-exec-1
|
||||
description:
|
||||
Check that exec exits for built-ins
|
||||
arguments: !-i!
|
||||
stdin:
|
||||
exec print hi
|
||||
echo still herre
|
||||
expected-stdout:
|
||||
hi
|
||||
expected-stderr-pattern: /.*/
|
||||
---
|
||||
|
||||
name: xxx-while-1
|
||||
description:
|
||||
Check the return value of while loops
|
||||
XXX need to do same for for/select/until loops
|
||||
stdin:
|
||||
i=x
|
||||
while [ $i != xxx ] ; do
|
||||
i=x$i
|
||||
if [ $i = xxx ] ; then
|
||||
false
|
||||
continue
|
||||
fi
|
||||
done
|
||||
echo loop1=$?
|
||||
|
||||
i=x
|
||||
while [ $i != xxx ] ; do
|
||||
i=x$i
|
||||
if [ $i = xxx ] ; then
|
||||
false
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo loop2=$?
|
||||
|
||||
i=x
|
||||
while [ $i != xxx ] ; do
|
||||
i=x$i
|
||||
false
|
||||
done
|
||||
echo loop3=$?
|
||||
expected-stdout:
|
||||
loop1=0
|
||||
loop2=0
|
||||
loop3=1
|
||||
---
|
||||
|
||||
name: xxx-status-1
|
||||
description:
|
||||
Check that blank lines don't clear $?
|
||||
arguments: !-i!
|
||||
stdin:
|
||||
(exit 1)
|
||||
echo $?
|
||||
(exit 1)
|
||||
|
||||
echo $?
|
||||
true
|
||||
expected-stdout:
|
||||
1
|
||||
1
|
||||
expected-stderr-pattern: /.*/
|
||||
---
|
||||
|
||||
name: xxx-status-2
|
||||
description:
|
||||
Check that $? is preserved in subshells, includes, traps.
|
||||
stdin:
|
||||
(exit 1)
|
||||
|
||||
echo blank: $?
|
||||
|
||||
(exit 2)
|
||||
(echo subshell: $?)
|
||||
|
||||
echo 'echo include: $?' > foo
|
||||
(exit 3)
|
||||
. ./foo
|
||||
|
||||
trap 'echo trap: $?' ERR
|
||||
(exit 4)
|
||||
echo exit: $?
|
||||
expected-stdout:
|
||||
blank: 1
|
||||
subshell: 2
|
||||
include: 3
|
||||
trap: 4
|
||||
exit: 4
|
||||
---
|
||||
|
||||
name: xxx-clean-chars-1
|
||||
description:
|
||||
Check MAGIC character is stuffed correctly
|
||||
stdin:
|
||||
echo `echo [<5B>`
|
||||
expected-stdout:
|
||||
[<5B>
|
||||
---
|
||||
|
||||
name: xxx-param-subst-qmark-1
|
||||
description:
|
||||
Check suppresion of error message with null string. According to
|
||||
POSIX, it shouldn't print the error as `word' isn't ommitted.
|
||||
stdin:
|
||||
unset foo
|
||||
x=
|
||||
echo x${foo?$x}
|
||||
expected-exit: 1
|
||||
expected-fail: yes
|
||||
expected-stderr-pattern: !/not set/
|
||||
---
|
||||
|
||||
name: xxx-param-_-1
|
||||
description:
|
||||
Check c flag is set.
|
||||
arguments: !-c!echo "[$-]"!
|
||||
expected-stdout-pattern: /^\[.*c.*\]$/
|
||||
---
|
||||
|
||||
name: env-prompt
|
||||
description:
|
||||
Check that prompt not printed when processing ENV
|
||||
env-setup: !ENV=./foo!
|
||||
file-setup: file 644 "foo"
|
||||
XXX=_
|
||||
PS1=X
|
||||
false && echo hmmm
|
||||
arguments: !-i!
|
||||
stdin:
|
||||
echo hi${XXX}there
|
||||
expected-stdout:
|
||||
hi_there
|
||||
expected-stderr: !
|
||||
XX
|
||||
---
|
||||
|
9
tests/version.t
Normal file
9
tests/version.t
Normal file
@@ -0,0 +1,9 @@
|
||||
name: version-1
|
||||
description:
|
||||
Check version of shell.
|
||||
category: pdksh
|
||||
stdin:
|
||||
echo $KSH_VERSION
|
||||
expected-stdout:
|
||||
@(#)PD KSH v5.2.14 99/07/13.2
|
||||
---
|
Reference in New Issue
Block a user