1 Eylül 2021 Çarşamba tarihinde Robert Elz <k...@munnari.oz.au> yazdı:

>     Date:        Wed, 1 Sep 2021 16:38:00 +0300
>     From:        "=?UTF-8?B?T8SfdXo=?= via austin-group-l at The Open
> Group" <austin-group-l@opengroup.org>
>     Message-ID:  <CAH7i3LpFk0TfxwpQny3ma6HzMptS
> qvsysq5nfzfxetr7yeq...@mail.gmail.com>
>
>   | true
>   | a=$? b=`exit 1` b=$? >`echo /dev/null; exit 2`
>   | echo $? $a $b
>
>   | Now, I wonder, what did I miss?
>
> That $? (the exit status) is defined only when a command completes.
> What it is in the middle of a command execution isn't specified.
>
>   | Where does it say in the standard that
>   | the value of parameter `?' is affected by redirections,
>
> It isn't the redirection, but the command substitution that generates
> the file name for the redirection.
>
>   | and that its
>   | value depends on assignments that appear earlier in the same command?
>
> All this stuff is just unspecified, the order in which all of this is
> carried out, and precisely when $? gets updated, isn't specified, if you
> want to achieve meaningful results, you need to split the one
> multi-assignemnt
> with redirect command into multiple commands.
>
> You get 1 0 0 from a shell which only sets $? when a command completes
> (and which does the redirect before the arg expansions).
>
> Getting 2 for $? comes because it all depends which of the two command
> substitutions is executed first (the last one executed provides $?), which
> depends upon whether the redirect happens first or the arg expansions, and
> for a command with no actual command word, that's unspecified
> (implementations
> are allowed to do it either way - which the standard allows, as as you see,
> different implementations do it different ways, and users need to be aware
> of that).
>
> Getting a non-zero value for a or b just means that $? is being internally
> updated when a value for it becomes available, rather than only when a
> command completes, about which as best I remember, nothing is said in the
> standard at all.


>
Oh, okay then. Thanks


> kre
>
>

-- 
Oğuz
  • $? 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