Hello,
Roland Mainz <[EMAIL PROTECTED]> writes:
> Is it normal that setting $ set -o nounset # in a function will keep
> this function enabled even when I enter another function ?
> For example:
> -- snip --
> $ /usr/bin/ksh93 -x -c 'function x { set -o nounset ; y; } ; function y
> { print "$foo" ; }>
> + x
> /usr/bin/ksh93[1]: x[1]: y: line 1: foo/usr/bin/ksh93[1]: x[1]: y: line
> 1: : parameter not set
> + set -o nounset
> /usr/bin/ksh93: line 1: foo/usr/bin/ksh93: line 1: foo/usr/bin/ksh93:
> line 1: foo/home/test001/ksh93/ast_ksh_20080202/build_i3: parameter not
> set
> -- snip --
> ... function "x" sets "set -o nounset" and function "y" (called by
> function "x") hits an error thanks to this flag. When exactly are these
> flags set/unset/restored (I assume the previous status is returned when
> leaving a function but the defaults are inherited from the parent
> function, right ?) ?
Seems like your last guess is right. This script:
--8<---------------cut here---------------start------------->8---
#!/opt/ast/bin/ksh
# -*- ksh -*-
unset_z='is set'
function x
{
print "unset_x1 $unset_x1"
y
print "unset_x2 $unset_x2"
}
function y
{
print "unset_y1 $unset_y1"
set -o nounset
z
}
function z
{
print "unset_z $unset_z"
}
print RUN 1
x
print RUN 2
unset unset_z
x
--8<---------------cut here---------------end--------------->8---
produces this output for me:
--8<---------------cut here---------------start------------->8---
RUN 1
unset_x1
unset_y1
unset_z is set
unset_x2
RUN 2
unset_x1
unset_y1
./unset.ksh[32]: x[9]: y[17]: z: line 22: unset_z: parameter not set
unset_x2
--8<---------------cut here---------------end--------------->8---
I'm using Version M 1993-12-28 s+ from 2008-02-02.
--
Wolfram Fenske
A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users