Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Greg Wooledge
On Tue, Jun 22, 2021 at 06:54:18PM -0700, Martin Jambon wrote: > This is confirmed by this definition from posix: > > A subshell environment shall be created as a duplicate of the shell > environment, except [...] > In the posix definition, a subshell > - is not necessarily implemented as a

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Martin Jambon
On 6/22/21 6:11 PM, Lawrence Velázquez wrote: On Tue, Jun 22, 2021, at 8:52 PM, Martin Jambon wrote: It's better. However, the reader is still left wondering what "the shell" is referring to in first sentence. Subshells aside, I have a hard time believing that "the process ID of the shell"

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Dale R. Worley
> It's not the brace command; it's the pipeline. > >> Minimal repro: >> >>$ sleep 1 & { wait $!; } | cat >>[1] 665454 >>bash: wait: pid 665454 is not a child of this shell Interestingly, this is almost trivial to clairfy: $ sleep 5 & { wait $!; } [1] 19069 [1]+ Done

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Lawrence Velázquez
On Tue, Jun 22, 2021, at 8:52 PM, Martin Jambon wrote: > It's better. However, the reader is still left wondering what "the > shell" is referring to in first sentence. Subshells aside, I have a hard time believing that "the process ID of the shell" confuses anybody in practice. Even POSIX

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Martin Jambon
On 6/22/21 5:00 PM, Lawrence Velázquez wrote: Maybe something like this would get the point across: ($$) Expands to the process ID of the shell. In a subshell, it expands to the value that $$ has in the invoking shell. It's better. However, the reader is still left

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Lawrence Velázquez
On Tue, Jun 22, 2021, at 6:32 PM, Martin Jambon wrote: > I would also mention pipelines here, since these are more commonly > used than () subshells. I don't know if there are other ways of > creating subshells. If that's all, I think it would be valuable > to mention those two cases rather than

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Martin Jambon
On 6/22/21 1:37 PM, Greg Wooledge wrote: On Tue, Jun 22, 2021 at 01:12:10PM -0700, Martin Jambon wrote: On 6/22/21 4:31 AM, Greg Wooledge wrote: A pipeline creates two or more subshells, one for each command in the pipeline. Therefore, your wait command is running in a different process than

Latest push for command substitutions

2021-06-22 Thread Chet Ramey
The latest devel branch push has a rewrite of parse_comsub() to recursively call the parser (yyparse()). I was finally able to get all the state working correctly, though it will probably only work with bison. Please run it through any tests or scripts you have so we can shake out any bugs

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Greg Wooledge
On Tue, Jun 22, 2021 at 01:12:10PM -0700, Martin Jambon wrote: > On 6/22/21 4:31 AM, Greg Wooledge wrote: > > A pipeline creates two or more subshells, one for each command in the > > pipeline. Therefore, your wait command is running in a different > > process than the one which created the sleep

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Martin Jambon
On 6/22/21 4:31 AM, Greg Wooledge wrote: On Tue, Jun 22, 2021 at 02:42:40AM -0700, Martin Jambon wrote: I ran into something that looks like a bug to me, although I'm not super familiar curly-brace command groups. Bash version: latest from GitHub mirror (commit ce23728: Bash-5.1 patch 7)

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Martin Jambon
On 6/22/21 6:15 AM, Chet Ramey wrote: On 6/22/21 5:42 AM, Martin Jambon wrote: Hello! I ran into something that looks like a bug to me, although I'm not super familiar curly-brace command groups. It's not the brace command; it's the pipeline. Thank you! It's the $$ that confused me since

Re: Feature request: index of index

2021-06-22 Thread Phi Debian
Meanwhile you may use functions to setup your variables something along those lines. PW$ function first-index { echo $1; } PW$ function last-index { shift $(($#-1)) ; echo $1; } PW$ declare -a array=([5]="hello" [11]="world" [42]="here") PW$ declare -i first_index=$(first-index ${!array[@]}) PW$

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Chet Ramey
On 6/22/21 5:42 AM, Martin Jambon wrote: Hello! I ran into something that looks like a bug to me, although I'm not super familiar curly-brace command groups. It's not the brace command; it's the pipeline. Minimal repro:   $ sleep 1 & { wait $!; } | cat   [1] 665454   bash: wait: pid

Re: 'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Greg Wooledge
On Tue, Jun 22, 2021 at 02:42:40AM -0700, Martin Jambon wrote: > I ran into something that looks like a bug to me, although I'm not super > familiar curly-brace command groups. > > Bash version: latest from GitHub mirror (commit ce23728: Bash-5.1 patch 7) > > Minimal repro: > > $ sleep 1 & {

'wait' in command group in pipeline fails to recognize child process

2021-06-22 Thread Martin Jambon
Hello! I ran into something that looks like a bug to me, although I'm not super familiar curly-brace command groups. Bash version: latest from GitHub mirror (commit ce23728: Bash-5.1 patch 7) Minimal repro: $ sleep 1 & { wait $!; } | cat [1] 665454 bash: wait: pid 665454 is not a

Re: bash completion after a multiline string

2021-06-22 Thread Phi Debian
May be posting a link is not appropriate so I cut/paste it here I bumped into this problem regarding bash completion, can't find reference to it. When doing $ echo foo "bar" /tm I got /tm expanded to /tmp/ that is indeed correct. But if I do $ echo foo "bar more bar" /tm No completion is