Open anowell opened 4 years ago
That sounds like it could be useful, and it might be a nice improvement over our current debug printing also. I wonder how we would want to represent some of these more complicated features in a cross-platform way:
full_env
stdout_stderr_swap
before_spawn
(This one involves arbitrary Rust code and definitely can't be represented in the shell. So we'd need to decide whether to print some placeholder or maybe return an error.)Interesting. I could go either way on displaying all the extra complexity, and I won't pretend to know how cross-platform this is, but for unix:
full_env
would typically be the default, and without the full env, you'd run env -i - mycmd
or env -i - foo=bar mycmd
to include specific env vars.stdout_stderr_swap
would probably be something like mycmd 3>&2 2>&1 1>&3-
before_spawn
- I got nothing. I find this API a bit strange: what if I spawn the Command
inside the before_spawn
handler? Not that you should change the design based on my off-handed observations without context to historical decisions, but my inclination would be toward a simpler: to_command(&self) -> Command
conversion helper (or impl From<Expression> for Command
) for cases where you need to work with the raw Command
type.
I was creating complex expressions using duct and found myself wanting ways to easily print out the shell command in a way that I could easily copy-paste debug in a bash (or similar) shell to debug, to be able to do something like:
I started with some custom simple escaping that seemed good enough for my use case, but I found shell_escape to be more a bit more complete and ended up with something like this:
Which allowed me to print out abnormally complex expressions like:
I could also imagine extending this to prefix environment variables to the shell string (e.g.
foo=bar mycmd arg1 'another arg'
). Just an idea; feel free to close if this doesn't fit into the scope of duct.