I don't usually carp on this list, especially to the author but I
respectively submit that reading the man page says typeset -x is
equivalent to export and
there is no reference to an exclusion to that if it's in a function.
Yes, it's said that typeset renders local scope but in the logical
English typeset -x seems
to be an exception. Bash and zsh accomplish this exception. What does
POSIX say or does it not?
Regards,
Mostyn
On 11/05/2010 07:09 AM, David Korn wrote:
Subject: Re: [ast-users] Is it correct that exporting function-local variable
causes the variable not to be exported if the function exporting the local
variable calls another function and this function calls an external command ?
--------
ksh93 -c 'function y { ksh -c "print \$ex" ; } ; function x {
typeset -x ex ; for ex in "foo" "bar" ; do export ex ; y ; done ; } ;
x'
With ksh93, variables are statically scoped whereas they are
dynamically scoped in ksh88.
Thus, since you have
typeset -x ex
in function x, this creates a local variable in x that will not
be seen in function y.
However, if you omit the typeset -x ex in function x and only
have export ex, then ex will be a global variable that is
exported and will therefore be known in function y.
Thus, this behavior is correct.
David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users