On 4/6/23 5:59 PM, Robert Elz wrote:
     Date:        Wed, 5 Apr 2023 10:35:58 -0400
     From:        "Chet Ramey via austin-group-l at The Open Group" 
<austin-group-l@opengroup.org>
     Message-ID:  <ad50dd74-a0dc-8fab-e416-917e45768...@case.edu>

   | A variant with slightly different semantics:
   |
   | (exit 8)
   | a=4 b=$(exit 42) c=$?
   | echo status:$? c=$c
   |
   | The standard is clear about what $? should be for the echo, but should it
   | be set fron the command substitution for the assignment to c?

It isn't really different semantics, it is the same thing.

The different semantics are that the standard specifies the status of the
simple command in terms of the command substitution that's part of the
assignment statement, so you have to hang onto it for a while.

We have this identical discussion every couple of years. At least the last
time produced interp 1150, which -- in true standards fashion -- attempted
to clarify the issue with additional obscure language.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

          • 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
    • Re: $? behaviou... Chet Ramey via austin-group-l at The Open Group
    • Re: $? behaviou... Robert Elz via austin-group-l at The Open Group

Reply via email to