-
Notifications
You must be signed in to change notification settings - Fork 454
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
var = read foo && echo foo
doesn't work
#376
Comments
I finally looked into this and figured out why it's happening. Backticks are evaluated with This can be overridden, so this can be fixed. The potential downsides of fixing it are:
On the whole, I think these downsides are minor, so I'm leaning towards piping stdin to backtick expressions. |
When you say stdin would be a shared resource do you mean something like the following could happen? test:
echo "I'm a file!" > file.txt
`cat file.txt | tr b x`
`echo "Bob"` might output BoxI'm a file! Like a piping or more along the lines of $ just test < echo "Robert!"
Roxert!I'm a file!
Bob Either possibility sounds very bad to me at the moment. I'd rather see a new function (like |
This change doesn't affect the way that justfile recipe lines inherit the standard input stream, so the behavior and output of recipe commands won't change. Also, the
You would always get:
In general, most commands only read from stdin if you don't give them any arguments, so this shouldn't break any existing, working justfiles. What I meant by stdin becoming a shared resource is that multiple backticks in a justfile will execute in some order, and just doesn't guarantee the order that backticks execute in. So if you have, for example:
and you do:
It's undefined if you'll get:
Or:
Note that recipe execution order is deterministic and will not change. Recipes execute in the order they are given on the command line, modulo dependencies between them, which are straightforward. But backticks in expressions may execute in any order. But they will execute in some order and not in parallel. So if you want to read two values into just variables, you could do:
I think this is reasonable behavior that won't do anything unexpected or broken, but definitely let me know if I've missed something. |
Also, this only affects backticks in just expressions. Backticks in recipe lines are still executed by the shell, so the behavior won't change at all there. |
In #374, @slisznia wanted a way to read a password from a user into an env variable. Unfortunately, for some strange reason, the following doesn't work:
The following works, and I'm not sure what just is doing differently when it runs backtick commands:
I'm not sure why this is the case. I won't have time to dig into this for the near future, so if someone wants to take a crack at it they are most welcome!
The text was updated successfully, but these errors were encountered: