Re: sh vs. bash -xc 'a=b c=$a'

2024-05-23 Thread alex xmb sw ratchev
if u var=value command ; the var's only for cmd and disappears afterwards if u var=val ; cmd ; its not for cmd , excepts exported and is set after cmd , usual behav old rule On Thu, May 23, 2024, 3:34 PM Robert Elz wrote: > Date:Thu, 23 May 2024 09:04:48 -0400 > From:

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-23 Thread Robert Elz
Date:Thu, 23 May 2024 09:04:48 -0400 From:Chet Ramey Message-ID: | The bash output clearly tells you the | order of operations, which is the whole purpose of -x. But it can be horribly misleading. Consider what bash does with this similar case (I used 5.3a1

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-23 Thread Chet Ramey
On 5/22/24 10:57 PM, Oğuz wrote: And some Bourne shells expand command substitutions first $ (exit 5) $ x=$? y=`exit 10` $ echo $x 10 It's worse than that. The v7 sh performed assignments right to left. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-23 Thread Chet Ramey
On 5/22/24 6:56 PM, Dan Jacobson wrote: It seems these should both make one line "+ a=b c=b" output, for s in sh bash do $s -xc 'a=b c=$a' done I mean they give the same results, but bash splits it into two lines, so the user reading the bash -x output cannot tell if one (correct) or two

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-22 Thread Robert Elz
Date:Thu, 23 May 2024 05:57:05 +0300 From:=?UTF-8?B?T8SfdXo=?= Message-ID: | On Thu, May 23, 2024 at 2:49 AM Steffen Nurpmeso wrote: | > Only to note that this is not portable. | Nor will NetBSD sh. That's right, and this is expressly unspecified in POSIX.

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-22 Thread Oğuz
On Thu, May 23, 2024 at 2:49 AM Steffen Nurpmeso wrote: > Only to note that this is not portable. > The FreeBSD shell will not assign "b" to "c" for this one! Nor will NetBSD sh. This lets you swap values of two variables without using a third $ x=1 y=2 $ x=$y y=$x $ echo $x $y 2 1 And some

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-22 Thread Steffen Nurpmeso
Greg Wooledge wrote in : |On Thu, May 23, 2024 at 06:56:01AM +0800, Dan Jacobson wrote: |> It seems these should both make one line "+ a=b c=b" output, |> |> for s in sh bash |> do $s -xc 'a=b c=$a' Only to note that this is not portable. The FreeBSD shell will not assign "b" to "c" for

Re: sh vs. bash -xc 'a=b c=$a'

2024-05-22 Thread Greg Wooledge
On Thu, May 23, 2024 at 06:56:01AM +0800, Dan Jacobson wrote: > It seems these should both make one line "+ a=b c=b" output, > > for s in sh bash > do $s -xc 'a=b c=$a' > done > > I mean they give the same results, but bash splits it into > two lines, so the user reading the bash -x output

sh vs. bash -xc 'a=b c=$a'

2024-05-22 Thread Dan Jacobson
It seems these should both make one line "+ a=b c=b" output, for s in sh bash do $s -xc 'a=b c=$a' done I mean they give the same results, but bash splits it into two lines, so the user reading the bash -x output cannot tell if one (correct) or two (incorrect) lines were used. They can tell with