[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PIPESTATUS differs from $? for compound command
From: |
Lawrence Velázquez |
Subject: |
Re: PIPESTATUS differs from $? for compound command |
Date: |
Thu, 12 Dec 2024 03:56:52 -0500 |
On Thu, Dec 12, 2024, at 2:01 AM, Mike Jonkmans wrote:
> Yes, the posix grammar doesn't allow it.
> But it is not clear, from the bash documentation,
> that a pipeline is not a command.
Sure, the documentation doesn't explicitly say that. But it also
doesn't say that pipelines are composed of pipelines, the way it
says that lists are composed of pipelines. So why would you make
that assumption?
> Moreover, bash accepts e.g.:
> ! ! false
> How can you parse that, without a pipeline being a command?
The yacc grammar uses two separate non-terminals to realize the
colloquial notion of a "pipeline":
command: simple_command
| shell_command
| shell_command redirection_list
| function_def
| coproc
;
shell_command: for_command
| case_command
| WHILE compound_list DO compound_list DONE
| UNTIL compound_list DO compound_list DONE
| select_command
| if_command
| subshell
| group_command
| arith_command
| cond_command
| arith_for_command
;
[...]
pipeline_command: pipeline
| BANG pipeline_command
| timespec pipeline_command
| timespec nullcmd_terminator
| BANG nullcmd_terminator
;
pipeline: pipeline '|' newline_list pipeline
| pipeline BAR_AND newline_list pipeline
| command
;
So "pipeline_command" is what you're after.
> And, as said, ksh allows the construct (! true | ! true).
> It is not impossible, it just is not posix.
Of course it's not impossible, it's just goofy. A pipeline like:
! true | ! true | ! true
looks like it's composed of several segments that are each being
individually "negated", but it's logically equivalent [*] to:
! ! ! true | true | true
so why allow the confusion? (POSIX doesn't permit the latter either,
which is consistent at least.)
[*]: Yes, I know that in bash ! ! just cancels out, so it probably
wouldn't be *exactly* the same.
--
vq
- Re: PIPESTATUS differs from $? for compound command, (continued)
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Ulrich Müller, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Phi Debian, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Chet Ramey, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/11
- Re: PIPESTATUS differs from $? for compound command, Andreas Schwab, 2024/12/11
- Re: PIPESTATUS differs from $? for compound command, Lawrence Velázquez, 2024/12/11
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command,
Lawrence Velázquez <=
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, Chet Ramey, 2024/12/12
- Re: PIPESTATUS differs from $? for compound command, Greg Wooledge, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Ulrich Müller, 2024/12/10
Re: PIPESTATUS differs from $? for compound command, Chet Ramey, 2024/12/10