On 05/04/2023 18:05, Harald van Dijk via austin-group-l at The Open
Group wrote:
On 05/04/2023 17:44, Oğuz wrote:
5 Nisan 2023 Çarşamba tarihinde Harald van Dijk <[email protected]
<mailto:[email protected]>> yazdı:
I am not sure which other ash based shells you were looking at,
/bin/sh on NetBSD and FreeBSD
Thanks. I indeed see the same results as you on a recent version of
FreeBSD sh (the one on the FreeBSD 13.1 installation media).
There is a legitimate benefit to this: swapping variables without an
additional helper variable actually works in that implementation.
a=1 b=2
a=$b b=$a
echo $b $a
Actually, I am seeing another legitimate benefit:
The standard is clear that in
export a="$b" b="$a"
the arguments to the 'export' command are expanded first, and then the
'export' command is run which performs the assignments, thus swapping
the values of 'a' and 'b', but also exporting their values.
It seems rather a shame that
export a=<...> b=<...>
and
a=<...> b=<...>
export a b
do not have the same effect, so that the 'export a b' line can be taken
out when exporting is not desired. Under the traditional ash behaviour,
these do have the same effect. This consistency, to me, is a good
argument in favour of the traditional behaviour and in favour of POSIX
permitting that behaviour.
Cheers,
Harald van Dijk