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

Re: [PATCH] spell-correct-word: avoid inf loop with neg arg

2024-05-22 Thread Chet Ramey
On 5/21/24 10:41 PM, Grisha Levit wrote: bash --norc -in <<< $'A \e-\cXs' I think I'd rather make negative counts work in the opposite direction. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech,

Re: [PATCH] dynamic-complete-history: avoid null ptr qsort UB

2024-05-22 Thread Chet Ramey
On 5/21/24 11:58 PM, Grisha Levit wrote: $ HISTFILE= bash --norc -in <<< $'#\n#\e\t' bashline.c:3720:16: runtime error: null pointer passed as argument 1, which is declared to never be null /usr/include/stdlib.h:971:30: note: nonnull attribute specified here SUMMARY: UndefinedBehaviorSanitizer:

Re: printf -u "$fd"?

2024-05-22 Thread Chet Ramey
On 5/22/24 12:32 AM, Zachary Santer wrote: On Tue, May 21, 2024 at 3:06 PM Chet Ramey wrote: On 5/21/24 11:14 AM, Zachary Santer wrote: On Tue, May 21, 2024 at 9:01 AM Chet Ramey wrote: On 5/21/24 6:17 AM, Zachary Santer wrote: I was wondering what the relationship between the devel and

Re: [PATCH] bashline: small leaks

2024-05-22 Thread Chet Ramey
On 5/21/24 11:34 AM, Grisha Levit wrote: - free directory_part when completing command words like `~/bin/' - free contents of matches when completing command words in old-style command substitutions Thanks for the report and patch. -- ``The lyf so short, the craft so long to lerne.'' -

Re: [PATCH] execute-named-command: fix small leaks

2024-05-22 Thread Chet Ramey
On 5/21/24 11:32 AM, Grisha Levit wrote: - free command if it is the empty string - free command before calling bound function, in case bound function does not return, like rl_abort Thanks for the report. I don't want to ring the bell if the command is the empty string, so I did this

Re: printf -u "$fd"?

2024-05-22 Thread Zachary Santer
On Wed, May 22, 2024 at 12:32 AM Zachary Santer wrote: > > In my Rocky Linux 9.1 VM: > $ bash --version > GNU bash, version 5.1.8(1)-release [...] > $ exec {fd_A}> >( cat > file_A.txt ) > $ exec {fd_B}> >( cat > file_B.txt ) > $ printf 'words\n' | tee /dev/fd/"${fd_A}" /dev/fd/"${fd_B}" > words >