mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-30 17:09:50 +02:00
commit bash-20060606 snapshot
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
BUILD_DIR=/usr/local/build/chet/bash/bash-current
|
||||
BUILD_DIR=/usr/local/build/bash/bash-current
|
||||
THIS_SH=$BUILD_DIR/bash
|
||||
PATH=$PATH:$BUILD_DIR
|
||||
|
||||
|
||||
@@ -148,3 +148,4 @@ expect 2 40
|
||||
2 40
|
||||
expect 5 20
|
||||
5 20
|
||||
5
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
a returns 5
|
||||
b returns 4
|
||||
c returns 3
|
||||
d returns 2
|
||||
in e
|
||||
e returned 25
|
||||
x is 25
|
||||
ZZ
|
||||
abcde
|
||||
defghi
|
||||
ZZ
|
||||
5
|
||||
0
|
||||
AVAR
|
||||
AVAR
|
||||
foo
|
||||
foo
|
||||
AVAR
|
||||
5
|
||||
5
|
||||
f1
|
||||
f1 ()
|
||||
{
|
||||
( return 5 );
|
||||
status=$?;
|
||||
echo $status;
|
||||
return $status
|
||||
}
|
||||
before: try to assign to FUNCNAME
|
||||
outside: FUNCNAME =
|
||||
before: FUNCNAME = func
|
||||
FUNCNAME = func2
|
||||
after: FUNCNAME = func
|
||||
outside2: FUNCNAME =
|
||||
function
|
||||
zf is a function
|
||||
zf ()
|
||||
{
|
||||
echo this is zf
|
||||
}
|
||||
f is a function
|
||||
f ()
|
||||
{
|
||||
echo f-x;
|
||||
echo f-y
|
||||
} 1>&2
|
||||
subshell
|
||||
f is a function
|
||||
f ()
|
||||
{
|
||||
echo f-x;
|
||||
echo f-y
|
||||
} 1>&2
|
||||
f2 is a function
|
||||
f2 ()
|
||||
{
|
||||
echo f2-a;
|
||||
function f3 ()
|
||||
{
|
||||
echo f3-a;
|
||||
echo f3-b
|
||||
} 1>&2;
|
||||
f3
|
||||
}
|
||||
subshell
|
||||
f2 is a function
|
||||
f2 ()
|
||||
{
|
||||
echo f2-a;
|
||||
function f3 ()
|
||||
{
|
||||
echo f3-a;
|
||||
echo f3-b
|
||||
} 1>&2;
|
||||
f3
|
||||
}
|
||||
f4 is a function
|
||||
f4 ()
|
||||
{
|
||||
echo f4-a;
|
||||
function f5 ()
|
||||
{
|
||||
echo f5-a;
|
||||
echo f5-b
|
||||
} 1>&2;
|
||||
f5
|
||||
} 2>&1
|
||||
subshell
|
||||
f4 is a function
|
||||
f4 ()
|
||||
{
|
||||
echo f4-a;
|
||||
function f5 ()
|
||||
{
|
||||
echo f5-a;
|
||||
echo f5-b
|
||||
} 1>&2;
|
||||
f5
|
||||
} 2>&1
|
||||
testgrp is a function
|
||||
testgrp ()
|
||||
{
|
||||
echo testgrp-a;
|
||||
{
|
||||
echo tg-x;
|
||||
echo tg-y
|
||||
} 1>&2;
|
||||
echo testgrp-b
|
||||
}
|
||||
subshell
|
||||
testgrp is a function
|
||||
testgrp ()
|
||||
{
|
||||
echo testgrp-a;
|
||||
{
|
||||
echo tg-x;
|
||||
echo tg-y
|
||||
} 1>&2;
|
||||
echo testgrp-b
|
||||
}
|
||||
funca is a function
|
||||
funca ()
|
||||
{
|
||||
( echo func-a )
|
||||
}
|
||||
funcb is a function
|
||||
funcb ()
|
||||
{
|
||||
( echo func-b )
|
||||
}
|
||||
funcc is a function
|
||||
funcc ()
|
||||
{
|
||||
( echo func-c ) 2>&1
|
||||
}
|
||||
func-a
|
||||
func-b
|
||||
func-c
|
||||
expect 5 10
|
||||
5 10
|
||||
expect 20
|
||||
20
|
||||
expect 5 20
|
||||
5 20
|
||||
expect 5 30
|
||||
5 30
|
||||
expect 2 40
|
||||
2 40
|
||||
expect 5 20
|
||||
5 20
|
||||
@@ -165,4 +165,12 @@ myfunction() {
|
||||
myfunction
|
||||
myfunction | cat
|
||||
|
||||
segv()
|
||||
{
|
||||
echo foo | return 5
|
||||
}
|
||||
|
||||
segv
|
||||
echo $?
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
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
|
||||
|
||||
# FUNCNAME tests
|
||||
func2()
|
||||
{
|
||||
echo FUNCNAME = $FUNCNAME
|
||||
}
|
||||
|
||||
func()
|
||||
{
|
||||
echo before: FUNCNAME = $FUNCNAME
|
||||
func2
|
||||
echo after: FUNCNAME = $FUNCNAME
|
||||
}
|
||||
|
||||
echo before: try to assign to FUNCNAME
|
||||
FUCNAME=7
|
||||
|
||||
echo outside: FUNCNAME = $FUNCNAME
|
||||
func
|
||||
echo outside2: FUNCNAME = $FUNCNAME
|
||||
|
||||
# test exported functions (and cached exportstr)
|
||||
zf()
|
||||
{
|
||||
echo this is zf
|
||||
}
|
||||
export -f zf
|
||||
|
||||
${THIS_SH} -c 'type -t zf'
|
||||
${THIS_SH} -c 'type zf'
|
||||
|
||||
${THIS_SH} ./func1.sub
|
||||
|
||||
# tests for functions whose bodies are not group commands, with and without
|
||||
# attached redirections
|
||||
${THIS_SH} ./func2.sub
|
||||
|
||||
# test for some posix-specific function behavior
|
||||
${THIS_SH} ./func3.sub
|
||||
|
||||
unset -f myfunction
|
||||
myfunction() {
|
||||
echo "bad shell function redirection"
|
||||
} >> /dev/null
|
||||
|
||||
myfunction
|
||||
myfunction | cat
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user