Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipelines involving printf hang #43

Closed
dspinellis opened this issue Jan 25, 2017 · 4 comments
Closed

Pipelines involving printf hang #43

dspinellis opened this issue Jan 25, 2017 · 4 comments
Assignees

Comments

@dspinellis
Copy link
Owner

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 added a commit that referenced this issue Jan 26, 2017
@mfragkoulis
Copy link
Collaborator

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
Copy link
Owner Author

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
Copy link
Owner Author

dspinellis commented Jan 26, 2017

A few more things remain to close this.

  • Statements (e.g. dgsh -c 'echo hi | {{ cat & cat & }} | cat') should error, not hang.
  • We should also handle correctly other builtins that can cause trouble.
  • Ideally, we should just auto-wrap builtins when needed, rather than remove them. This will make it easier to integrate dgsh functionality into the bash distribution.

@dspinellis dspinellis reopened this Jan 26, 2017
@mfragkoulis
Copy link
Collaborator

mfragkoulis commented Jan 26, 2017

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.

mfragkoulis added a commit that referenced this issue Jan 26, 2017
but prioritise for execution dgsh commands
over shell builtins with the same name
Fix issue #43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants