Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread felix
Le Mon, Apr 22, 2024 at 07:44:48AM +0100, Kerin Millar a écrit : > On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: > > ... > > if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' > > >/dev/null ; then > > echo Don't print this' > > fi ; echo ${?@Q} ${PIPESTATUS[@]@A} $(( $? ${

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Kerin Millar
On Mon, 22 Apr 2024, at 7:44 AM, Kerin Millar wrote: > On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: >> Hi, >> >> Comming on this very old thread: >> >> On Wed, 4 Dec 2013 14:40:11 -0500, Greg Wooledge wrote: >>> >>> The most obvious difference is that $? is shorter. >>> >>> $? is also POSIX stan

Re: Examples of concurrent coproc usage?

2024-04-22 Thread Martin D Kealey
On Mon, 22 Apr 2024, 09:17 Carl Edquist, wrote: > When I say "token" I just mean a record with whatever delimiter you're > referring to using. Ok that makes sense. Assuming the reading stops after consuming the first delimiter (which is > necessary for the 'read' builtin), then you end up wit

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Andreas Kähäri
On Mon, Apr 22, 2024 at 09:15:52AM +0200, felix wrote: > Le Mon, Apr 22, 2024 at 07:44:48AM +0100, Kerin Millar a écrit : > > On Mon, 22 Apr 2024, at 7:13 AM, felix wrote: > > > ... > > > if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' > > > >/dev/null ; then > > > echo Don

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Oğuz
On Mon, Apr 22, 2024 at 10:24 AM Kerin Millar wrote: > I cannot find anything in the manual that concretely explains why bash > behaves as it does in this instance. Me neither, but the current behavior is useful. Take `while false | false; do :; done' for example, if bash reported the status of

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread felix
Le Mon, Apr 22, 2024 at 10:56:03AM +0300, Oğuz a écrit : > > Me neither, but the current behavior is useful. I agree! Anyway, reading man page, `$?` have to be equivalent to `${PIPESTATUS[-1]}`! which is not always the case. > I've never seen anything like that in a real shell script. I have to

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Martin D Kealey
On Mon, 22 Apr 2024, 18:13 felix, wrote: > Hi, > > Coming on this very old thread: > > [the] man page say[s]: > > PIPESTATUS > An array variable (see Arrays below) containing a list of exit > status values from the processes in the most-recently-executed > foreg

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Greg Wooledge
On Mon, Apr 22, 2024 at 08:13:16AM +0200, felix wrote: > Then after some tests: > > if ls /wrong/path | wc | cat - /wrong/path | sed 'w/wrong/path' >/dev/null > ; then > echo Don't print this' > fi ; echo ${?@Q} ${PIPESTATUS[@]@A} $(( $? ${PIPESTATUS[@]/#/+} )) > > ls: cannot access

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Kerin Millar
On Mon, 22 Apr 2024, at 8:56 AM, Oğuz wrote: > On Mon, Apr 22, 2024 at 10:24 AM Kerin Millar wrote: >> I cannot find anything in the manual that concretely explains why bash >> behaves as it does in this instance. > > Me neither, but the current behavior is useful. Take `while false | Very much

Re: bash newgrp(1) -c option? Fwd: /usr/bin/sg in Cygwin?

2024-04-22 Thread Chet Ramey
On 4/22/24 1:41 AM, Cedric Blancher wrote: Chet, The Solaris ksh93-integration version of ksh93 has a newgrp -c option (David Korn, Glenn Fowler and Roland Mainz did implement it), which works like ksh93/bash -c, and executes script under the requested group, and upon exiting resumes the old she

Re: Erasing sensitive data from memory?

2024-04-22 Thread Chet Ramey
On 4/21/24 2:16 PM, Zachary Santer wrote: Does bash malloc new memory for the variable every time it's set? If so, I'd imagine the memory storing the prior version of the variable is free'd, but continues to contain the sensitive data. It depends on the malloc version. The bash malloc overwrit

Re: bash parallel build: make[1]: warning: -j16 forced in submake: resetting jobserver mode.

2024-04-22 Thread Chet Ramey
On 4/21/24 7:21 PM, Dan Shelton wrote: On Sat, 13 Apr 2024 at 17:27, Chet Ramey wrote: On 4/13/24 12:40 AM, Cedric Blancher wrote: Good morning! Building bash HEAD on Cygwin 3.5.3 and Debian Linux 11 in make parallel mode issues a warning, which looks like a Makefile bug: $ make -h 16 ... m

Re: bash parallel build: make[1]: warning: -j16 forced in submake: resetting jobserver mode.

2024-04-22 Thread Chet Ramey
On 4/22/24 12:53 AM, Oğuz wrote: On Monday, April 22, 2024, Dan Shelton wrote: Passing -j to submakes ist just wrong. All submakes and the parent should be part of ONE GNU make jobserver. Is MFLAGS used for anything other than compatibility with ancient makes? Why doesn't GNU make just stri

Re: bash parallel build: make[1]: warning: -j16 forced in submake: resetting jobserver mode.

2024-04-22 Thread Chet Ramey
On 4/20/24 2:02 AM, Cedric Blancher wrote: You can check what env the submake in question has and which recipe runs it and see where this setting comes from. We were only using make -j16 all at the bash base dir. That should NOT trigger this warning. Bash passes ${MFLAGS} to makes in subdire

Re: Examples of concurrent coproc usage?

2024-04-22 Thread Chet Ramey
On 4/20/24 6:04 PM, Carl Edquist wrote: I think this is _definitely_ true for the BC coproc in the bcalc example. But it's kind of a distraction to get hung up on that detail, because in the general case there may very well be other scenarios where it would be appropriate to, um, _nudge_ the c

Re: Examples of concurrent coproc usage?

2024-04-22 Thread Chet Ramey
On 4/20/24 7:11 PM, Carl Edquist wrote: I could always enable it in the devel branch and see what happens with the folks who use that. It would be three years after any release when distros would put it into production anyway. Oh, fun  :) I'll enable it in the next devel branch push, so wit

Re: Examples of concurrent coproc usage?

2024-04-22 Thread Chet Ramey
On 4/21/24 7:42 AM, Martin D Kealey wrote: On Sat, 20 Apr 2024 at 01:14, Chet Ramey > wrote: On 4/17/24 8:55 PM, Martin D Kealey wrote: > Has anyone tried asking any of the kernel teams (Linux, BSD, or other) to > add a new system call such as read

Re: [Help-bash] difference of $? and ${PIPESTATUS[0]}

2024-04-22 Thread Chet Ramey
On 4/22/24 2:13 AM, felix wrote: I could explain that '$?' is result of bash's if...then...fi group command executed correctly and PIPESTATUS hold result of "most-recently-executed foreground pipeline", but man page say: PIPESTATUS An array variable (see Arrays below) containin

Re: bash parallel build: make[1]: warning: -j16 forced in submake: resetting jobserver mode.

2024-04-22 Thread Chet Ramey
On 4/22/24 11:58 AM, Chet Ramey wrote: On 4/20/24 2:02 AM, Cedric Blancher wrote: You can check what env the submake in question has and which recipe runs it and see where this setting comes from. We were only using make -j16 all at the bash base dir. That should NOT trigger this warning. B