On 01/09/2021 17:22, Geoff Clare via austin-group-l at The Open Group wrote:
Harald van Dijk wrote, on 01 Sep 2021:

The second problem is the redirection. Based on the above, command
substitutions in a redirection are supposed to affect the exit status just
as any other command substitution, but the standard says:

   3. Redirections shall be performed as described in Redirection.

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

This means the command substitution in your redirection is supposed to be
performed prior to that in the variable assignment.

After the list, the standard says:

     In the preceding list, the order of steps 3 and 4 may be reversed
     if no command name results from step 2 or if the command name
     matches the name of a special built-in utility

Ah, thank you. That means the outputs "1 0 0" and "2 0 0" are both equally correct. I assume the outputs "1 2 1" and "2 0 1" do indicate shell bugs.

Cheers,
Harald van Dijk

  • $? in a simple comman... Oğuz via austin-group-l at The Open Group
    • Re: $? in a simp... Harald van Dijk via austin-group-l at The Open Group
      • Re: $? in a ... Geoff Clare via austin-group-l at The Open Group
        • Re: $? i... Harald van Dijk via austin-group-l at The Open Group
    • Re: $? in a simp... Robert Elz via austin-group-l at The Open Group
      • Re: $? in a ... Oğuz via austin-group-l at The Open Group
      • Re: $? in a ... Harald van Dijk via austin-group-l at The Open Group
      • Re: $? in a ... Robert Elz via austin-group-l at The Open Group
        • Re: $? i... Chet Ramey via austin-group-l at The Open Group
          • Re: ... Joerg Schilling via austin-group-l at The Open Group
            • ... Scott Lurndal via austin-group-l at The Open Group
              • ... Joerg Schilling via austin-group-l at The Open Group
            • ... Chet Ramey via austin-group-l at The Open Group
      • Re: $? in a ... Robert Elz via austin-group-l at The Open Group

Reply via email to