Clash with shell environment variable syntax
clbarnes opened this issue · 3 comments
Great project, looks very ergonomic to use!
Would you consider designating interpolation variables differently? $var_name already has a meaning and is very commonly used in shell scripts, and there may be times where the user wants to refer to external environment variables. There aren't many characters which don't already have a meaning, but even something like $$ would drastically reduce the number of potential clashes - it's used to get the PID but that's far less common than environment variable use.
Thanks for your reporting. If you read the readme, you will find that I just want this library to handle redirection and piping the same as in shell script. Other features of shell script are not preferred or even discouraged, and they could usually be implemented in the better rust way.
For global environment variable, you can use std::env::var and std::env::set_var to achieve the goal. It will report error if environment variable is not present, and also include other checks to avoid silent failures.
For command environment variable, yes it is better to make DEBUG=1 command_x ... work, which can call https://doc.rust-lang.org/std/process/struct.Command.html#method.env internally.
Thanks for your response! Using std to get the global environment variable as a rust variable and then using that rust variable does make sense - and encourages people to do more sanity checking on the value. Would you be open to including this explicitly in the docs? I could do a PR if so.
Sure thanks, all the PRs are very welcome, especially the docs part, which is also I am trying to focus on to make this library more useful.