mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-11 06:00:49 +02:00
Imported from ../bash-2.01.tar.gz.
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
a()
|
||||
{
|
||||
x=$((x - 1))
|
||||
return 5
|
||||
}
|
||||
|
||||
b()
|
||||
{
|
||||
x=$((x - 1))
|
||||
a
|
||||
echo a returns $?
|
||||
return 4
|
||||
}
|
||||
|
||||
c()
|
||||
{
|
||||
x=$((x - 1))
|
||||
b
|
||||
echo b returns $?
|
||||
return 3
|
||||
}
|
||||
|
||||
d()
|
||||
{
|
||||
x=$((x - 1))
|
||||
c
|
||||
echo c returns $?
|
||||
return 2
|
||||
}
|
||||
|
||||
e()
|
||||
{
|
||||
d
|
||||
echo d returns $?
|
||||
echo in e
|
||||
x=$((x - 1))
|
||||
return $x
|
||||
}
|
||||
|
||||
f()
|
||||
{
|
||||
e
|
||||
echo e returned $?
|
||||
echo x is $x
|
||||
return 0
|
||||
}
|
||||
|
||||
x=30
|
||||
f
|
||||
|
||||
# make sure unsetting a local variable preserves the `local' attribute
|
||||
f1()
|
||||
{
|
||||
local zz
|
||||
zz=abcde
|
||||
echo $zz
|
||||
unset zz
|
||||
zz=defghi
|
||||
echo $zz
|
||||
}
|
||||
|
||||
zz=ZZ
|
||||
echo $zz
|
||||
f1
|
||||
echo $zz
|
||||
|
||||
unset -f f1
|
||||
f1()
|
||||
{
|
||||
return 5
|
||||
}
|
||||
|
||||
( f1 )
|
||||
echo $?
|
||||
|
||||
unset -f f1
|
||||
f1()
|
||||
{
|
||||
sleep 5
|
||||
return 5
|
||||
}
|
||||
|
||||
f1 &
|
||||
wait
|
||||
echo $?
|
||||
|
||||
unset -f f1
|
||||
|
||||
f1()
|
||||
{
|
||||
echo $AVAR
|
||||
printenv AVAR
|
||||
}
|
||||
|
||||
AVAR=AVAR
|
||||
echo $AVAR
|
||||
f1
|
||||
AVAR=foo f1
|
||||
echo $AVAR
|
||||
|
||||
unset -f f1
|
||||
# make sure subshells can do a `return' if we're executing in a function
|
||||
f1()
|
||||
{
|
||||
( return 5 )
|
||||
status=$?
|
||||
echo $status
|
||||
return $status
|
||||
}
|
||||
|
||||
f1
|
||||
echo $?
|
||||
|
||||
declare -F f1 # should print just the name
|
||||
declare -f f1 # should print the definition, too
|
||||
|
||||
# no functions should be exported, right?
|
||||
declare -xF
|
||||
declare -xf
|
||||
Reference in New Issue
Block a user