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

Pass stdin handle to backtick process #409

Merged
merged 1 commit into from
Apr 17, 2019
Merged

Pass stdin handle to backtick process #409

merged 1 commit into from
Apr 17, 2019

Conversation

casey
Copy link
Owner

@casey casey commented Apr 17, 2019

Backtick processes are launched (via the brev crate) using Command::output, which by default prevents stdin from being inherited.

This diff passes stdin through. This allows backtick commands to read from stdin, and so fixes #376 and #374.

In particular, this allows:

password := `read PASSWORD && echo $PASSWORD`

ssh:
  echo {{password}}

To support this change, integration tests are modified to take an additional string argument, which is written to the just child process's stdin. Existing tests are passed "", and a few tests have been added that read from stdin and echo it, to make sure that it actually works.

cc: @slisznia

@casey
Copy link
Owner Author

casey commented Apr 17, 2019

It should be noted that the order that backticks execute in is unspecified and may change in the future.

Currently, dependencies between variables determine backtick execution order, not the order they appear in source. This justfile:

b := a + `echo bar`
a := `echo foo`

foo:
  echo {{b}}

will run echo foo before echo bar, even though echo foo appears a line after echo bar. However, this is an implementation detail, and may change.

So, if multiple top-level backticks read from stdin, the order that they read from stdin is undefined.

@casey casey merged commit 792b7a2 into master Apr 17, 2019
@casey casey deleted the backtick-stdin branch April 17, 2019 02:52
@casey casey mentioned this pull request Apr 17, 2019
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

Successfully merging this pull request may close these issues.

var = read foo && echo foo doesn't work
1 participant