[Toybox] The "var=value function" shell issue.

enh enh at google.com
Mon Jun 10 09:20:38 PDT 2019


On Mon, Jun 10, 2019 at 9:17 AM enh <enh at google.com> wrote:
>
> chet ramey replied
> (https://www.mail-archive.com/austin-group-l@opengroup.org/msg04071.html)
> that this has actually been changed to "undefined" in the

[grr, stupid gmail --- why is there even a keyboard shortcut for send,
and why is it one that's so easy to hit by accident?!]

...current published version of POSIX. (pro tip: always search
"opengroup 2018" to try to get the _current_ one. pagerank seems to do
a bad job with POSIX otherwise.)

he also says that he wants to make [what we all think is the right
behavior] the default in POSIX mode in future versions of bash too.

> On Mon, Jun 10, 2019 at 8:41 AM enh <enh at google.com> wrote:
> >
> > dash, ksh, mksh, and zsh all agree with POSIX. seems like bash is the
> > exception (so POSIX is at least "right" in their limited sense of
> > "describe existing behavior").
> >
> > i've forwarded a version of this question to the POSIX mailing list,
> > since there are few things that they like to argue about more than
> > historical shell behaviors :-)
> >
> > (but i'm expected "WAI, bash is wrong", even though bash makes the most sense.)
> >
> > On Sun, Jun 9, 2019 at 4:07 PM Rob Landley <rob at landley.net> wrote:
> > >
> > > I've reached the part of the posix shell stuff (section 2.9.1: simple commands)
> > > that specifies this behavior, and posix is wrong:
> > >
> > >   If no command name results, or if the command name is a special built-in or
> > >   function, variable assignments shall affect the current execution environment.
> > >   Otherwise, the variable assignments shall be exported for the execution
> > >   environment of the command and shall not affect the current execution
> > >   environment except as a side-effect of the expansions performed in step 4.
> > >
> > > A) This is not what bash does, or has ever done:
> > >
> > >   $ hello() { echo boing=$BOING; }
> > >   $ BOING=123 hello
> > >   $ echo $BOING
> > >   $
> > >
> > > B) doing it would be STUPID because there's no reason to DO an assignment on the
> > > same line rather than on the previous line unless you want to constrain the
> > > lifetime of the variables. (The semicolon character exists, you can do X=y; echo
> > > $X; It's literally one extra character.)
> > >
> > > Rob
> > > _______________________________________________
> > > Toybox mailing list
> > > Toybox at lists.landley.net
> > > http://lists.landley.net/listinfo.cgi/toybox-landley.net



More information about the Toybox mailing list