2001-04-02 14:31:39 +02:00
|
|
|
|
%prep
|
|
|
|
|
|
|
|
|
|
storepath=($path)
|
|
|
|
|
|
|
|
|
|
mkdir command.tmp command.tmp/dir1 command.tmp/dir2
|
|
|
|
|
|
|
|
|
|
cd command.tmp
|
|
|
|
|
|
|
|
|
|
print '#!/bin/sh\necho This is top' >tstcmd
|
2001-08-22 17:59:27 +02:00
|
|
|
|
|
2001-04-02 14:31:39 +02:00
|
|
|
|
print '#!/bin/sh\necho This is dir1' >dir1/tstcmd
|
2001-08-22 17:59:27 +02:00
|
|
|
|
|
2001-04-02 14:31:39 +02:00
|
|
|
|
print '#!/bin/sh\necho This is dir2' >dir2/tstcmd
|
|
|
|
|
|
|
|
|
|
chmod 755 tstcmd dir1/tstcmd dir2/tstcmd
|
|
|
|
|
|
|
|
|
|
%test
|
|
|
|
|
./tstcmd
|
|
|
|
|
0:./prog execution
|
|
|
|
|
>This is top
|
|
|
|
|
|
|
|
|
|
path=($ZTST_testdir/command.tmp/dir1
|
|
|
|
|
$ZTST_testdir/command.tmp/dir2
|
|
|
|
|
.)
|
|
|
|
|
tstcmd
|
|
|
|
|
path=($storepath)
|
|
|
|
|
0:path (1)
|
|
|
|
|
>This is dir1
|
|
|
|
|
|
|
|
|
|
path=(. command.tmp/dir{1,2})
|
|
|
|
|
tstcmd
|
|
|
|
|
path=($storepath)
|
|
|
|
|
0:path (2)
|
|
|
|
|
>This is top
|
|
|
|
|
|
|
|
|
|
functst() { print $# arguments:; print -l $*; }
|
|
|
|
|
functst "Eines Morgens" "als Gregor Samsa"
|
|
|
|
|
functst ""
|
|
|
|
|
functst "aus unr<6E>higen Tr<54>umen erwachte"
|
|
|
|
|
foo="fand er sich in seinem Bett"
|
|
|
|
|
bar=
|
|
|
|
|
rod="zu einem ungeheuren Ungeziefer verwandelt."
|
|
|
|
|
functst $foo $bar $rod
|
|
|
|
|
# set up alias for next test
|
|
|
|
|
alias foo='print This is alias one'
|
|
|
|
|
0:function argument passing
|
|
|
|
|
>2 arguments:
|
|
|
|
|
>Eines Morgens
|
|
|
|
|
>als Gregor Samsa
|
|
|
|
|
>1 arguments:
|
|
|
|
|
>
|
|
|
|
|
>1 arguments:
|
|
|
|
|
>aus unr<6E>higen Tr<54>umen erwachte
|
|
|
|
|
>2 arguments:
|
|
|
|
|
>fand er sich in seinem Bett
|
|
|
|
|
>zu einem ungeheuren Ungeziefer verwandelt.
|
|
|
|
|
|
|
|
|
|
alias foo='print This is alias two'
|
|
|
|
|
fn() { foo; }
|
|
|
|
|
fn
|
|
|
|
|
0:Aliases in functions
|
|
|
|
|
>This is alias one
|
|
|
|
|
|
|
|
|
|
foo='Global foo'
|
|
|
|
|
traptst() { local foo="Local foo"; trap 'print $foo' EXIT; }
|
|
|
|
|
traptst
|
|
|
|
|
0:EXIT trap environment
|
|
|
|
|
>Global foo
|
|
|
|
|
|
|
|
|
|
functst() { return 0; print Ha ha; return 1; }
|
|
|
|
|
functst
|
|
|
|
|
0:return (1)
|
|
|
|
|
|
|
|
|
|
functst() { return 1; print Ho ho; return 0; }
|
|
|
|
|
functst
|
|
|
|
|
1:return (2)
|
|
|
|
|
|
|
|
|
|
unfunction functst
|
|
|
|
|
fpath=(.)
|
|
|
|
|
print "print This is functst." >functst
|
|
|
|
|
autoload functst
|
|
|
|
|
functst
|
|
|
|
|
0:autoloading (1)
|
|
|
|
|
>This is functst.
|
|
|
|
|
|
|
|
|
|
unfunction functst
|
|
|
|
|
print "functst() { print This, too, is functst; }; print Hello." >functst
|
|
|
|
|
typeset -fu functst
|
|
|
|
|
functst
|
|
|
|
|
functst
|
|
|
|
|
0:autoloading with initialization
|
|
|
|
|
>Hello.
|
|
|
|
|
>This, too, is functst
|
|
|
|
|
|
|
|
|
|
unfunction functst
|
|
|
|
|
print "print Yet another version" >functst
|
|
|
|
|
functst() { autoload -X; }
|
|
|
|
|
functst
|
|
|
|
|
0:autoloading via -X
|
|
|
|
|
>Yet another version
|
|
|
|
|
|
|
|
|
|
chpwd() { print Changed to $PWD; }
|
|
|
|
|
cd .
|
|
|
|
|
unfunction chpwd
|
|
|
|
|
0q:chpwd
|
|
|
|
|
>Changed to $ZTST_testdir/command.tmp
|
|
|
|
|
|
2006-11-08 11:38:05 +01:00
|
|
|
|
chpwd() { print chpwd: changed to $PWD; }
|
|
|
|
|
chpwdfn1() { print chpwdfn1: changed to $PWD; }
|
|
|
|
|
chpwdfn2() { print chpwdfn2: changed to $PWD; }
|
|
|
|
|
chpwd_functions=(chpwdfn1 '' chpwdnonexistentfn chpwdfn2)
|
|
|
|
|
cd .
|
|
|
|
|
unfunction chpwd
|
|
|
|
|
unset chpwd_functions
|
|
|
|
|
0q:chpwd_functions
|
|
|
|
|
>chpwd: changed to $ZTST_testdir/command.tmp
|
|
|
|
|
>chpwdfn1: changed to $ZTST_testdir/command.tmp
|
|
|
|
|
>chpwdfn2: changed to $ZTST_testdir/command.tmp
|
|
|
|
|
|
2001-04-02 14:31:39 +02:00
|
|
|
|
# Hard to test periodic, precmd and preexec non-interactively.
|
|
|
|
|
|
|
|
|
|
fn() { TRAPEXIT() { print Exit; }; }
|
|
|
|
|
fn
|
|
|
|
|
0:TRAPEXIT
|
|
|
|
|
>Exit
|
|
|
|
|
|
2008-08-07 18:25:14 +02:00
|
|
|
|
unsetopt DEBUG_BEFORE_CMD
|
2001-04-02 14:31:39 +02:00
|
|
|
|
unfunction fn
|
|
|
|
|
print 'TRAPDEBUG() {
|
|
|
|
|
print Line $LINENO
|
|
|
|
|
}
|
|
|
|
|
:
|
|
|
|
|
unfunction TRAPDEBUG
|
|
|
|
|
' > fn
|
|
|
|
|
autoload fn
|
|
|
|
|
fn
|
|
|
|
|
rm fn
|
|
|
|
|
0:TRAPDEBUG
|
|
|
|
|
>Line 1
|
|
|
|
|
>Line 1
|
|
|
|
|
|
2008-08-07 18:25:14 +02:00
|
|
|
|
unsetopt DEBUG_BEFORE_CMD
|
2001-04-02 14:31:39 +02:00
|
|
|
|
unfunction fn
|
|
|
|
|
print 'trap '\''print Line $LINENO'\'' DEBUG
|
|
|
|
|
:
|
|
|
|
|
trap - DEBUG
|
|
|
|
|
' > fn
|
|
|
|
|
autoload fn
|
|
|
|
|
fn
|
|
|
|
|
rm fn
|
|
|
|
|
0:trap DEBUG
|
|
|
|
|
>Line 1
|
2004-07-29 17:09:51 +02:00
|
|
|
|
>Line 2
|
2001-04-02 14:31:39 +02:00
|
|
|
|
|
|
|
|
|
TRAPZERR() { print Command failed; }
|
|
|
|
|
true
|
|
|
|
|
false
|
|
|
|
|
true
|
|
|
|
|
false
|
|
|
|
|
unfunction TRAPZERR
|
|
|
|
|
0:TRAPZERR
|
|
|
|
|
>Command failed
|
|
|
|
|
>Command failed
|
|
|
|
|
|
|
|
|
|
trap 'print Command failed again.' ZERR
|
|
|
|
|
true
|
|
|
|
|
false
|
|
|
|
|
true
|
|
|
|
|
false
|
|
|
|
|
trap - ZERR
|
|
|
|
|
0:trap ZERR
|
|
|
|
|
>Command failed again.
|
|
|
|
|
>Command failed again.
|
2010-12-05 19:33:07 +01:00
|
|
|
|
|
|
|
|
|
false
|
|
|
|
|
sleep 1000 &
|
|
|
|
|
print $?
|
|
|
|
|
kill $!
|
|
|
|
|
0:Status reset by starting a backgrounded command
|
|
|
|
|
>0
|
2013-10-24 07:45:02 +02:00
|
|
|
|
|
|
|
|
|
repeat 2048; do (: | : | while false; do
|
|
|
|
|
break
|
|
|
|
|
done;
|
|
|
|
|
print "${pipestatus[@]}")
|
|
|
|
|
ZTST_hashmark
|
2013-10-24 18:31:02 +02:00
|
|
|
|
done | sort | uniq -c | sed 's/^ *//'
|
2013-10-24 07:45:02 +02:00
|
|
|
|
0:Check whether `$pipestatus[]' behaves.
|
2013-10-24 18:31:02 +02:00
|
|
|
|
>2048 0 0 0
|
2013-10-24 07:45:02 +02:00
|
|
|
|
F:This test checks for a bug in `$pipestatus[]' handling. If it breaks then
|
|
|
|
|
F:the bug is still there or it reappeared. See workers-29973 for details.
|