Robert Elz wrote in
 <6906.1680741...@jacaranda.noi.kre.to>:
 ...
 |The issue here is that people tend to think of
 | a=1
 |as a command.   It isn't (not as people think of it anyway).
 |But with that mindset they treat
 | a=1 b=$a c=$b
 |as 3 commands, one after the other.   It isn't.

To come back to the bug i reported to FreeBSD ([1]).

  [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251770

There i say

  3385   4.23        Variable Assignment
  3386               In the shell command language, a word consisting of the 
following parts:
  3387               varname=value
  3388               When used in a context where assignment is defined to 
occur and at no other time, the value
  3389               (representing a word or field) shall be assigned as the 
value of the variable denoted by varname.
  3390               Note:          For further information, see XCU Section 
2.9.1 (on page 2365).

  ---

  75482   2.9.1        Simple Command

  75495                    4.    Each variable assignment shall be expanded for 
tilde expansion, parameter expansion,
  75496                          command substitution, arithmetic expansion, 
and quote removal prior to assigning the
  75497                          value.

  ---

  75501          Variable assignments shall be performed as follows:
  75502             •   If no command name results, variable assignments shall 
affect the current execution
  75503                 environment.

  ---

  So everything should be handled sequentially, making it a bug.

And that is true, no?  If expansion has to take place, and the
assignment has been performed, .. it has been performed?

  ---

  75504             •   If the command name is not a special built-in utility 
or function, the variable assignments
  [.]
  75507                 4. In this case it is unspecified:
  75508                   — Whether or not the assignments are visible for 
subsequent expansions in step 4
  75509                   — Whether variable assignments made as side-effects 
of these expansions are visible for
  75510                     subsequent expansions in step 4, or in the current 
shell execution environment, or
  75511                     both

  ---

  So it allows to setup the "execution environment of the command" entirely 
from the current environment, which is effectively read-only.  As you say.

So maybe null command and that is not a bug?
But all shells except FreeBSD do this; also from the report:

  #?2|kent$ for s in dash bash mksh bosh; do $s -c 'du=ich wir='"'"'hey 
'"'"'$du; echo $wir'; done
  hey ich
  hey ich
  hey ich
  hey ich

I am no shell expert whatsoever.  My mailer will never support
that (except for assignment in arithmetic expression eg $((i=1))):

     This behaviour is different to the SHELL[644], which is a programming
     language with syntactic elements of clearly defined semantics, and there‐
     fore capable to sequentially expand and evaluate individual elements of a
     line.  ‘? set one=spoon two=$one’ for example will never assign ‘spoon’
     to two, because it is the command set[275] that performs the assignment,
     long after the expansion has happened.

So i am out.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

            • ... Oğuz via austin-group-l at The Open Group
            • ... Harald van Dijk via austin-group-l at The Open Group
    • Re: $? behaviou... Harald van Dijk via austin-group-l at The Open Group
      • Re: $? beha... Chet Ramey via austin-group-l at The Open Group
        • Re: $? ... Harald van Dijk via austin-group-l at The Open Group
          • Re:... Chet Ramey via austin-group-l at The Open Group
            • ... Harald van Dijk via austin-group-l at The Open Group
      • Re: $? beha... Robert Elz via austin-group-l at The Open Group
        • Re: $? ... Chet Ramey via austin-group-l at The Open Group
    • Re: $? behaviou... Robert Elz via austin-group-l at The Open Group
      • Re: $? beha... Steffen Nurpmeso via austin-group-l at The Open Group
      • Re: $? beha... Robert Elz via austin-group-l at The Open Group
        • Re: $? ... Oğuz via austin-group-l at The Open Group
        • Re: $? ... Robert Elz via austin-group-l at The Open Group
  • Re: $? behaviour aft... Robert Elz via austin-group-l at The Open Group

Reply via email to