[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sh vs. bash -xc 'a=b c=$a'
From: |
Robert Elz |
Subject: |
Re: sh vs. bash -xc 'a=b c=$a' |
Date: |
Thu, 23 May 2024 12:30:03 +0700 |
Date: Thu, 23 May 2024 05:57:05 +0300
From: =?UTF-8?B?T8SfdXo=?= <oguzismailuysal@gmail.com>
Message-ID:
<CAH7i3LowwzCnP-pcQAMw6+ggKDoa6zi41P2Pi98fpZhXyfpdBQ@mail.gmail.com>
| On Thu, May 23, 2024 at 2:49 AM Steffen Nurpmeso <steffen@sdaoden.eu> wrote:
| > Only to note that this is not portable.
| Nor will NetBSD sh.
That's right, and this is expressly unspecified in POSIX.
But I think this aspect is missing the point of the OP's message,
which might have been better illustrated without stepping into
unspecified behaviour using
$SHELL -x -c 'x=1 y=2'
I can see the point, this is two var-assigns on a single (empty)
command, not two commands, which
$SHELL -x -c 'x=1 ; y=2'
would be (and which is fully specified to be each fully executed
before the next is started, avoiding the other issue).
As a comparison consider
$SHELL -x -c 'x=1 y=2 :'
which the first above is almost equivalent to (the difference is
the exit status should there be any command substitutions involved).
However, I don't really see that this should matter all that much.
(-x output is not specified anywhere, just that it happens).
kre