Re: nofork command substitution bugs

2024-01-12 Thread Chet Ramey
On 1/12/24 1:06 PM, Oğuz wrote: Why would that be unexpected, since you're explicitly running something in the calling shell's context, with the expected side effects to that environment? I wasn't clear. This doesn't exit the shell bash-5.3$ exec foo bash: exec: foo: not found

Re: nofork command substitution bugs

2024-01-12 Thread Oğuz
On Fri, Jan 12, 2024 at 7:05 PM Chet Ramey wrote: > Nofork command substitution freezes the jobs list, because you don't > want jobs appearing and disappearing in the list while you're running > word expansion. If the jobs list is frozen, wait -n doesn't even try > wa

Re: nofork command substitution bugs

2024-01-12 Thread Chet Ramey
On 1/4/24 8:36 AM, Oğuz wrote: These bugs affect the development branch only. 1. `wait -n' doesn't work inside nofork command substitution. I think it should, or wait without `-n' shouldn't work either, or what works and what doesn't should be documented. Nofork com

nofork command substitution bugs

2024-01-04 Thread Oğuz
These bugs affect the development branch only. 1. `wait -n' doesn't work inside nofork command substitution. I think it should, or wait without `-n' shouldn't work either, or what works and what doesn't should be documented. $ sleep 3 & sleep 1; echo ${| w

Error handling with nofork command substitution

2023-08-22 Thread jm
Hi, With the new funsub syntax ${ cmd;} and ${| cmd;} that encourages returning the value of $REPLY to the caller, I've been thinking about an idiomatic way of doing error handling and propagation that may call for a new shell option or new type of funsub. So the idea is natural, when a function

Re: nofork command substitution

2023-05-25 Thread Daniel Douglas
These are both very useful!

Re: nofork command substitution

2023-05-25 Thread Chet Ramey
On 5/25/23 1:19 PM, Robert Elz wrote: Date:Thu, 25 May 2023 10:17:01 -0400 From:Chet Ramey Message-ID: | a nofork command substitution is | '${' compound_list '}', you omitted the extra char there, not that it matters for the purpo

Re: nofork command substitution

2023-05-25 Thread Robert Elz
Date:Thu, 25 May 2023 10:17:01 -0400 From:Chet Ramey Message-ID: | a nofork command substitution is | '${' compound_list '}', you omitted the extra char there, not that it matters for the purpose here. | The difference, as you say, i

Re: nofork command substitution

2023-05-25 Thread Chet Ramey
A group command is '{' compound_list '}', a nofork command substitution is '${' compound_list '}', and a command substitution is '$(' compound_list ')'. (Similar to how a subshell command is '(' compound_list ')

Re: nofork command substitution

2023-05-25 Thread Chet Ramey
On 5/25/23 6:29 AM, Koichi Murase wrote: 2023年5月24日(水) 22:27 Chet Ramey : [...] Thanks for testing it. Thank you for all the explanations and clarifications. Both are valid, but don't get too fond of ${(command)} -- I'm going to remove it in favor of people using ${ (command); } if they wa

Re: nofork command substitution

2023-05-25 Thread Koichi Murase
2023年5月25日(木) 21:13 Robert Elz : > | Does that mean ${(command)} would be explicitly unsupported even > | though {(command)} is allowed for the brace grouping? > > The two are mostly unrelated. Yes, they are independent, but there is still a "choice" to make the new grammar similar to the exis

Re: nofork command substitution

2023-05-25 Thread Robert Elz
Date:Thu, 25 May 2023 19:29:40 +0900 From:Koichi Murase Message-ID: | Does that mean ${(command)} would be explicitly unsupported even | though {(command)} is allowed for the brace grouping? The two are mostly unrelated. | Would other cases without semicolon

Re: nofork command substitution

2023-05-25 Thread Koichi Murase
2023年5月24日(水) 22:27 Chet Ramey : > > [...] > > Thanks for testing it. Thank you for all the explanations and clarifications. > Both are valid, but don't get too fond of ${(command)} -- I'm going to > remove it in favor of people using ${ (command); } if they want a subshell. Does that mean ${(co

Re: nofork command substitution

2023-05-24 Thread Chet Ramey
On 5/23/23 4:17 PM, Grisha Levit wrote: An interactive shell gets confused (PS1 shown instead of PS2) when using newline as the first character of the substitution: $ bash --norc -i <<<$'${\n:;}' bash-5.2$ ${ bash-5.2$ :;} Thanks for the report. Chet -- ``The lyf so short, the craft so long

Re: nofork command substitution

2023-05-24 Thread Chet Ramey
On 5/23/23 4:17 PM, Grisha Levit wrote: Things don't seem to work right with an empty funsub: bash --pretty-print <<<'${ }' ${ ; } It should allow the empty command substitution, like $(), and not add the `;' when it reconstitutes the text. -- ``The lyf so short, the craft so long to lerne.

Re: nofork command substitution

2023-05-24 Thread Chet Ramey
On 5/23/23 6:52 AM, Koichi Murase wrote: I really appreciate that the feature ${ command; } is finally implemented. I have a function that mimics the behavior of the nofork command substitution in my project. I changed the function to switch to use the new nofork command substitutions in new

Re: nofork command substitution

2023-05-23 Thread Grisha Levit
An interactive shell gets confused (PS1 shown instead of PS2) when using newline as the first character of the substitution: $ bash --norc -i <<<$'${\n:;}' bash-5.2$ ${ bash-5.2$ :;} Things don't seem to work right with an empty funsub: bash --pretty-print <<<'${ }' ${ ; } $ bash -c '${ }'

Re: nofork command substitution

2023-05-23 Thread Koichi Murase
2023年5月16日(火) 2:35 Chet Ramey : > The latest devel branch push has the initial implementation of `nofork' > command substitution. The excerpt from the info manual describing it is > appended. > > Please test it out, and find the places I missed. Thanks. I really appreci

Re: nofork command substitution

2023-05-22 Thread Martijn Dekker
Op 22-05-2023 om 16:18 schreef Chet Ramey: I'd call that a bug. It's not how mksh documents this type of command substitution to work. ksh93 documents the parsing the same way. So it does, yet ksh93 also accepts omitting the ;. The only documentation of this is in the legacy changelog: 08-03

Re: nofork command substitution

2023-05-22 Thread Chet Ramey
On 5/19/23 2:42 PM, Robert Elz wrote: Date:Fri, 19 May 2023 12:03:51 -0400 From:Chet Ramey Message-ID: <0a85095a-1665-d936-b4fa-118dd158e...@case.edu> | Maybe, and certainly possible, but a more likely use is just a simple | assignment to REPLY. In such c

Re: nofork command substitution

2023-05-19 Thread Grisha Levit
This will be a very neat feature to have. One thing I'm excited about is the ability to cleanly perform assignments during prompt expansion (e.g. to capture information during PS0 or PS4 expansion). Something I suspect people will complain about is that this change makes some polyglot zsh/bash sc

Re: nofork command substitution

2023-05-19 Thread Chet Ramey
On 5/19/23 12:39 PM, alex xmb ratchev wrote: after ${| set -- 1 2 3 } , 1 2 3 are no more .. right ? ;} or space} to end .. ? The portion of the documentation I posted says: "the close brace must be in a position where a reserved word may appear (i.e., preceded by a command terminator s

Re: nofork command substitution

2023-05-19 Thread Chet Ramey
On 5/19/23 11:56 AM, alex xmb ratchev wrote: Command substitution is a word expansion; word expansions are performed on words; command substitution occurs as part of a word. That all seems self-evident. The only reason to mention it is the quirk required to have the close brace a

Re: nofork command substitution

2023-05-19 Thread Chet Ramey
On 5/19/23 7:36 AM, alex xmb ratchev wrote: 'C ..' ' ..' '| ..' .. i dont get it The `C' is the result of how info renders @var, used to indicate meta- syntactic variables (COMMAND is another). In other formats, it would be more apparent that it's not a literal `C' and that it's like the `COM

Re: Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 22:08 Chet Ramey wrote: > I don't think this ever made it to the list. > > > -- Forwarded message -- > From: Chet Ramey > To: "Ángel" > Cc: chet.ra...@case.edu > Bcc: > Date: Wed, 17 May 2023 11:53:46 -0400 > Su

Fwd: Re: nofork command substitution

2023-05-19 Thread Chet Ramey
I don't think this ever made it to the list.--- Begin Message --- On 5/16/23 5:40 PM, Ángel wrote: On 2023-05-15 at 13:35 -0400, Chet Ramey wrote: There is an alternate form of command substitution: ${C COMMAND; } I find this description confusing, as it looks like a literal 'C'.

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 21:11 Greg Wooledge wrote: > On Fri, May 19, 2023 at 06:35:50PM +0200, alex xmb ratchev wrote: > > so that i understand , > > > > var=${ awk ... } > > There's no reason to use this new thing if you're calling awk, because > awk is an external program. You might as well just

Re: nofork command substitution

2023-05-19 Thread Greg Wooledge
On Fri, May 19, 2023 at 06:35:50PM +0200, alex xmb ratchev wrote: > so that i understand , > > var=${ awk ... } There's no reason to use this new thing if you're calling awk, because awk is an external program. You might as well just use var=$( awk ... ) instead. Either way, you're going to for

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 20:43 Robert Elz wrote: > Date:Fri, 19 May 2023 12:03:51 -0400 > From:Chet Ramey > Message-ID: <0a85095a-1665-d936-b4fa-118dd158e...@case.edu> > > > | Maybe, and certainly possible, but a more likely use is just a simple > | assignment to RE

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
is there a difference between } and ;} / ' }' On Fri, May 19, 2023, 20:43 Robert Elz wrote: > Date:Fri, 19 May 2023 12:03:51 -0400 > From:Chet Ramey > Message-ID: <0a85095a-1665-d936-b4fa-118dd158e...@case.edu> > > > | Maybe, and certainly possible, but a more lik

Re: nofork command substitution

2023-05-19 Thread Robert Elz
Date:Fri, 19 May 2023 12:03:51 -0400 From:Chet Ramey Message-ID: <0a85095a-1665-d936-b4fa-118dd158e...@case.edu> | Maybe, and certainly possible, but a more likely use is just a simple | assignment to REPLY. In such cases, the value to be assigned needs to come

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 18:35 alex xmb ratchev wrote: > > > On Fri, May 19, 2023, 18:04 Chet Ramey wrote: > >> On 5/19/23 6:11 AM, Robert Elz wrote: >> > Date:Thu, 18 May 2023 22:14:28 -0400 >> > From:"Dale R. Worley" >> > Message-ID: <874jo9kqyj@hobgoblin.aria

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 18:04 Chet Ramey wrote: > On 5/19/23 6:11 AM, Robert Elz wrote: > > Date:Thu, 18 May 2023 22:14:28 -0400 > > From:"Dale R. Worley" > > Message-ID: <874jo9kqyj@hobgoblin.ariadne.com> > > > >| Chet Ramey writes: > >| > Bash allows

Re: nofork command substitution

2023-05-19 Thread Chet Ramey
On 5/19/23 6:11 AM, Robert Elz wrote: Date:Thu, 18 May 2023 22:14:28 -0400 From:"Dale R. Worley" Message-ID: <874jo9kqyj@hobgoblin.ariadne.com> | Chet Ramey writes: | > Bash allows the close brace to be joined to the remaining | > characters in the

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
hello .. On Fri, May 19, 2023, 16:29 Chet Ramey wrote: > On 5/18/23 10:14 PM, Dale R. Worley wrote: > > Chet Ramey writes: > >> Bash allows the close brace to be joined to the remaining > >> characters in the word without being followed by a shell metacharacter > >> as a reserved word would usu

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 14:55 Greg Wooledge wrote: > On Fri, May 19, 2023 at 02:25:15PM +0200, alex xmb ratchev wrote: > > On Fri, May 19, 2023, 13:54 Greg Wooledge wrote: > > > > > On Fri, May 19, 2023 at 01:36:44PM +0200, alex xmb ratchev wrote: > > > > 'C ..' > > > > ' ..' > > > > '| ..' > > >

Re: nofork command substitution

2023-05-19 Thread Chet Ramey
On 5/18/23 10:14 PM, Dale R. Worley wrote: Chet Ramey writes: Bash allows the close brace to be joined to the remaining characters in the word without being followed by a shell metacharacter as a reserved word would usually require. I had to read this a couple of times to figure out what it m

Re: nofork command substitution

2023-05-19 Thread Chet Ramey
On 5/18/23 9:58 PM, Dale R. Worley wrote: Ángel writes: I suggest: There is an alternate form of command substitution: ${ COMMAND; } and clarify later the other variants in addition to a space: The character following the open brace must be a space, tab, newline, '(', or '|

Re: nofork command substitution

2023-05-19 Thread Greg Wooledge
On Fri, May 19, 2023 at 02:25:15PM +0200, alex xmb ratchev wrote: > On Fri, May 19, 2023, 13:54 Greg Wooledge wrote: > > > On Fri, May 19, 2023 at 01:36:44PM +0200, alex xmb ratchev wrote: > > > 'C ..' > > > ' ..' > > > '| ..' > > > > > > .. i dont get it > > > > Yeah, the wording isn't ideal. I

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 14:25 alex xmb ratchev wrote: > > > On Fri, May 19, 2023, 13:54 Greg Wooledge wrote: > >> On Fri, May 19, 2023 at 01:36:44PM +0200, alex xmb ratchev wrote: >> > 'C ..' >> > ' ..' >> > '| ..' >> > >> > .. i dont get it >> >> Yeah, the wording isn't ideal. I'd start it out l

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
On Fri, May 19, 2023, 13:54 Greg Wooledge wrote: > On Fri, May 19, 2023 at 01:36:44PM +0200, alex xmb ratchev wrote: > > 'C ..' > > ' ..' > > '| ..' > > > > .. i dont get it > > Yeah, the wording isn't ideal. I'd start it out like this: > yea better .. ${ COMMAND; } > ${| COMMAND; } >

Re: nofork command substitution

2023-05-19 Thread Greg Wooledge
On Fri, May 19, 2023 at 01:36:44PM +0200, alex xmb ratchev wrote: > 'C ..' > ' ..' > '| ..' > > .. i dont get it Yeah, the wording isn't ideal. I'd start it out like this: ${ COMMAND; } ${| COMMAND; } Execute COMMAND in the current execution environment The first form (where the c

Re: nofork command substitution

2023-05-19 Thread alex xmb ratchev
'C ..' ' ..' '| ..' .. i dont get it On Mon, May 15, 2023, 19:35 Chet Ramey wrote: > The latest devel branch push has the initial implementation of `nofork' > command substitution. The excerpt from the info manual describing it is > appended. &

Re: nofork command substitution

2023-05-19 Thread Robert Elz
Date:Thu, 18 May 2023 22:14:28 -0400 From:"Dale R. Worley" Message-ID: <874jo9kqyj@hobgoblin.ariadne.com> | Chet Ramey writes: | > Bash allows the close brace to be joined to the remaining | > characters in the word without being followed by a shell metacha

Re: nofork command substitution

2023-05-18 Thread Dale R. Worley
Chet Ramey writes: > Bash allows the close brace to be joined to the remaining > characters in the word without being followed by a shell metacharacter > as a reserved word would usually require. I had to read this a couple of times to figure out what it means. In particular "the word" isn't wel

Re: nofork command substitution

2023-05-18 Thread Dale R. Worley
Ángel writes: > I suggest: > >> There is an alternate form of command substitution: >> >> ${ COMMAND; } > > and clarify later the other variants in addition to a space: > >> The character following the open brace must be a space, tab, >> newline, '(', or '|', and the close brace must

Re: nofork command substitution

2023-05-16 Thread Ángel
On 2023-05-15 at 13:35 -0400, Chet Ramey wrote: > There is an alternate form of command substitution: > > ${C COMMAND; } I find this description confusing, as it looks like a literal 'C'. I suggest: > There is an alternate form of command substitution: > > ${ COMMAND; } a

Re: nofork command substitution

2023-05-15 Thread Chet Ramey
On 5/15/23 2:54 PM, Oğuz İsmail Uysal wrote: On 5/15/23 9:51 PM, Chet Ramey wrote: Everything is shared between the comsub and its caller, with a couple of documented exceptions. So it's just like calling `fg' in the current execution environment, but capturing the output. Oh, okay then. Thanks

Re: nofork command substitution

2023-05-15 Thread Oğuz İsmail Uysal
On 5/15/23 9:51 PM, Chet Ramey wrote: Everything is shared between the comsub and its caller, with a couple of documented exceptions. So it's just like calling `fg' in the current execution environment, but capturing the output. Oh, okay then. Thanks. How about this?     $ declare -i x     $ y

Re: nofork command substitution

2023-05-15 Thread Chet Ramey
On 5/15/23 2:42 PM, Oğuz İsmail Uysal wrote: On 5/15/23 8:35 PM, Chet Ramey wrote: Please test it out     $ cat     ^Z     [1]+  Stopped cat     $ x=${ fg;}     foo     foo     <^C or ^D here>     $ declare -p x     declare -- x="cat"     $ Is this intended? So far

Re: nofork command substitution

2023-05-15 Thread Oğuz İsmail Uysal
On 5/15/23 8:35 PM, Chet Ramey wrote: Please test it out     $ cat     ^Z     [1]+  Stopped cat     $ x=${ fg;}     foo     foo     <^C or ^D here>     $ declare -p x     declare -- x="cat"     $ Is this intended?

nofork command substitution

2023-05-15 Thread Chet Ramey
The latest devel branch push has the initial implementation of `nofork' command substitution. The excerpt from the info manual describing it is appended. Please test it out, and find the places I missed. Thanks. Chet == There is an alternate form of command substitution: