Closed dspinellis closed 7 years ago
Fixed in https://github.com/dspinellis/dgsh/commit/1a204066f404daa6a7afd5319f6e68c86d03409d
Please note that newline is now treated as an operator for distinguishing commands (with unrelated IO) in a multipipe block. This is required in order to maintain an unambiguous grammar.
For example, this simple script:
{{
echo hi &
echo there &
}} |
cat
becomes
{{
echo hi
echo there
}} |
cat
where echo hi
, echo there
, and }}
must be in different lines.
Otherwise a syntax error will occur.
Something must be wrong in the way {{
is treated. Syntactically it should have the same treatment as {
.
[dds@stereo dgsh]$ {{
> echo hi
> echo there
> }} | paste
hi there
[dds@stereo dgsh]$ { echo hi ; echo there ; } | paste
hi
there
[dds@stereo dgsh]$ {{ echo hi ; echo there ; }} | paste
dgsh: syntax error near unexpected token `;'
As the commit states, commands in a multipipe block run asynchronously.
Therefore the newline operator (\n
) and the semicolon connector (;
) adhere to the semantics of the multipipe block when used in it, that is, they signify asynchronous execution.
The default connector for async execution in Bash (&
) can also be used.
For example, the four following scripts are equivalent:
{{
echo hi &
echo there &
}} |
cat
{{
echo hi
echo there
}} |
cat
{{ echo hi ; echo there ; }} | cat
{{ echo hi & echo there & }} | cat
Can't commands within a multipipe block be executed asynchronously by default? This is what happens in linear pipes and bash's process substitution. Is there ever a case for synchronous execution?