matklad / xshell

Apache License 2.0
675 stars 28 forks source link

Clarify in which sense the shell provides "independence of the host environment" #75

Open RalfJung opened 1 year ago

RalfJung commented 1 year ago

The docs say

Reliability: no shell injection by construction, good error messages with file paths, non-zero exit status is an error, independence of the host environment, etc.

I first thought this would mean that the shell doesn't forward the entire host environment to the called programs. However, a quick test with cmd!(Shell::new()?, "env").run()? showed that the environment is forwarded. It might be worth clarifying what is meant by "independence" here.

lnicola commented 1 year ago

I think it's supposed to mean "host application working directory", not specifically environment variables. Being able to opt in to some of those might be useful, though.

matklad commented 1 year ago

That’s confusing! What I meant was rather that, if you use bash, you need to worry whether grep is a gnu grep or bsd grep, but, if you use Rust+xshell, you’ll just do line processing within your process, and it’ll work the same on Linux, windows, and Mac. That’s not an absolute truth, but with bash you by default gain dependency on ambient environment you program runs in, while in Rust (and with xshell in particular) default is cross platform by default.

Probably should have said “same behavior across platforms” there.