On Wednesday 28 September 2005 10:04 am, Andreas Schwab wrote:
Akim Demaille [EMAIL PROTECTED] writes:
if (local foo) /dev/null 21; then :; else
local () { true; }
fi
Note that local is only valid in function context, so this will always
produce a failure.
For pedant points, that's
Paul == Paul Eggert [EMAIL PROTECTED] writes:
local isn't in POSIX so I'd avoid it in portable scripts.
Doh. Thanks.
For what it's worth, I briefly searched for this issue and found these
bug reports dated this year where someone used local in a shell
script and someone else
Akim Demaille [EMAIL PROTECTED] writes:
Also, maybe I am paranoid, but would you trust shells to support
conditional function definitions? Or function definitions in eval?
No, you're not paranoid. But I think I would trust it, yes.
Admittedly it might take some iterations to get the test
* Akim Demaille wrote on Wed, Sep 28, 2005 at 09:51:23AM CEST:
I can actually define local to do nothing and use an external
maintainer-check to grep'n check them.
Also, maybe I am paranoid, but would you trust shells to support
conditional function definitions? Or function definitions in
Akim Demaille [EMAIL PROTECTED] writes:
if (local foo) /dev/null 21; then :; else
local () { true; }
fi
Note that local is only valid in function context, so this will always
produce a failure.
Andreas.
--
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH,
Andreas == Andreas Schwab [EMAIL PROTECTED] writes:
Akim Demaille [EMAIL PROTECTED] writes:
if (local foo) /dev/null 21; then :; else
local () { true; }
fi
Note that local is only valid in function context, so this will always
produce a failure.
Thanks, I didn't know. How about
* Akim Demaille wrote on Wed, Sep 28, 2005 at 01:36:11PM CEST:
Thanks, I didn't know. How about this then?
(
foo=bar
test_local () {
local foo=foo
}
test_local
test $foo = bar
) || local () {
case $1 in
*=*) eval $1;;
esac
}
That does
Now that there are no doubts about the portability of shell functions
(in the sense that there's always a shell on the machine that supports
function ---and maybe the documentation should reflect this), I'm
curious about the support of return and local. Is there anything
known about them? ISTR
Akim Demaille [EMAIL PROTECTED] writes:
Now that there are no doubts about the portability of shell functions
(in the sense that there's always a shell on the machine that supports
function ---and maybe the documentation should reflect this),
Yes, it should.
I'm curious about the support of
Andreas Schwab [EMAIL PROTECTED] writes:
Paul Eggert [EMAIL PROTECTED] writes:
Assuming you don't need recursion, here's a thought. Use local, but
stick to the convention that all variable names are unique. On
systems that don't support local, define a function named local
that warns if
Paul Eggert [EMAIL PROTECTED] writes:
Assuming you don't need recursion, here's a thought. Use local, but
stick to the convention that all variable names are unique. On
systems that don't support local, define a function named local
that warns if any of its arguments is a variable whose
11 matches
Mail list logo