Re: Bug: temporary assignments vs shell function

2011-07-31 Thread Rudolf Polzer
On Mon, Aug 01, 2011 at 12:19:04AM +0200, Jilles Tjoelker wrote: > On Thu, Jul 14, 2011 at 12:09:15PM +0200, Rudolf Polzer wrote: > > I just retested with that very command, and yes, the FreeBSD /bin/sh > > does behave the "non-POSIX" (and "obvious") way, and so does the > > Solaris /bin/sh. > > Y

Re: Bug: temporary assignments vs shell function

2011-07-31 Thread Jilles Tjoelker
On Thu, Jul 14, 2011 at 12:09:15PM +0200, Rudolf Polzer wrote: > I just retested with that very command, and yes, the FreeBSD /bin/sh > does behave the "non-POSIX" (and "obvious") way, and so does the > Solaris /bin/sh. Yes, FreeBSD /bin/sh is not POSIX compliant here. Because the current behaviou

Re: Bug: temporary assignments vs shell function

2011-07-14 Thread Jonathan Nieder
Rudolf Polzer wrote: > So basically - when using an assignment for the duration of a shell command > execution, an explicit subshell must be used in portable scripts, as > interpretation of this construct differs among shells and thus cannot be > relied > on. If "shell command execution" means "

Re: Bug: temporary assignments vs shell function

2011-07-14 Thread Rudolf Polzer
On Thu, Jul 14, 2011 at 04:26:16AM -0500, Jonathan Nieder wrote: > Hi, > > Rudolf Polzer wrote: > > > foo=bar func > > echo "foo is now $foo" > > > > will export foo=bar in global scope (i.e. it affects the execution > > environment > > after the function call). > [...] > > A shell function howe

Re: Bug: temporary assignments vs shell function

2011-07-14 Thread Jonathan Nieder
Hi, Rudolf Polzer wrote: > foo=bar func > echo "foo is now $foo" > > will export foo=bar in global scope (i.e. it affects the execution environment > after the function call). [...] > A shell function however isn't a "special built-in" and also counts as a > "command name", thus the last echo lin

Bug: temporary assignments vs shell function

2011-07-14 Thread Rudolf Polzer
Hi, I noticed a little bug: func() { echo "Inside the shell function, foo is $foo" } foo=foo foo=bar func echo "foo is now $foo" will export foo=bar in global scope (i.e. it affects the execution environment after the function call). This is inconsistent with calls to commands (both bui