Re: sh portability questions

2005-09-29 Thread Keith Marshall
On Wednesday 28 September 2005 10:04 am, Andreas Schwab wrote: > Akim Demaille <[EMAIL PROTECTED]> writes: > > if (local foo) >/dev/null 2>&1; then :; else > >   local () { true;  } > > fi > > Note that local is only valid in function context, so this will always > produce a failure. For pedant po

Re: sh portability questions

2005-09-28 Thread Ralf Wildenhues
* 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 >

Re: sh portability questions

2005-09-28 Thread Akim Demaille
>>> "Andreas" == Andreas Schwab <[EMAIL PROTECTED]> writes: > Akim Demaille <[EMAIL PROTECTED]> writes: >> if (local foo) >/dev/null 2>&1; then :; else >> local () { true; } >> fi > Note that local is only valid in function context, so this will always > produce a failure. Thanks, I didn'

Re: sh portability questions

2005-09-28 Thread Andreas Schwab
Akim Demaille <[EMAIL PROTECTED]> writes: > if (local foo) >/dev/null 2>&1; 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, Max

Re: sh portability questions

2005-09-28 Thread Ralf Wildenhues
* 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 definiti

Re: sh portability questions

2005-09-28 Thread Paul Eggert
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

Re: sh portability questions

2005-09-28 Thread Akim Demaille
>>> "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

Re: sh portability questions

2005-09-28 Thread Ralf Wildenhues
Just a couple of random thoughts: * Paul Eggert wrote on Wed, Sep 28, 2005 at 12:36:06AM CEST: > Andreas Schwab <[EMAIL PROTECTED]> writes: > > Paul Eggert <[EMAIL PROTECTED]> writes: > > > >> Assuming you don't need recursion, here's a thought. I believe this is a decent assumption for the funct

Re: sh portability questions

2005-09-27 Thread Andreas Schwab
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 variabl

Re: sh portability questions

2005-09-27 Thread Paul Eggert
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"

Re: sh portability questions

2005-09-27 Thread Paul Eggert
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 suppo

sh portability questions

2005-09-27 Thread Akim Demaille
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? IS