dspinellis / dgsh

Shell supporting pipelines to and from multiple processes
http://www.spinellis.gr/sw/dgsh/
Other
323 stars 23 forks source link

Pipelines involving printf hang #43

Closed dspinellis closed 7 years ago

dspinellis commented 7 years ago

The following command works fine.

dgsh -c 'echo hi | {{  cat & echo there & }} | cat'

The following command hangs.

dgsh -c 'echo hi | {{  cat & printf there & }} | cat'
mfragkoulis commented 7 years ago

The hang was due to the treatment of printf as a builtin.

That said the graph dgsh -c 'echo hi | {{ cat & printf there & }} | cat' is awkward because echo cannot provide multiple outputs.

dgsh -c '{{ echo hi & printf there & }} | cat' would be more appropriate.

However, the output is only hi if printf does not use a newline. The following works normally: dgsh -c '{{ echo hi & printf "there\n" & }} | cat'

dspinellis commented 7 years ago

Calling printf now works correctly even without a newline. Perhaps you didn't notice thethere before the prompt? (It would have been a serious problem if we treated newlines specially at this level.)

$ dgsh -c '{{ echo hi & printf there & }} | cat'
hi
there$
dspinellis commented 7 years ago

A few more things remain to close this.

mfragkoulis commented 7 years ago

The graph dgsh -c 'echo hi | {{ cat & printf there & }} | cat' is totally legitimate and the handling is the expected; the command runs and terminates normally. Don't mind me, it was late last night :-) The graph dgsh -c 'echo hi | {{ cat & cat & }} | cat' is not allowed at the moment because of the presence of two flexible commands in a multiple block (we will revisit this in issue #4 -- multipipe blocks). The graph now exits with an error, it does not hang. Rephrased 1/3 and checked it.