synek317 / shellfn

Rust proc macro for easily and safely use shell scripts in rust
MIT License
208 stars 4 forks source link

Thoughts on str versus OsStr #6

Open sebastianblunt opened 5 years ago

sebastianblunt commented 5 years ago

Currently I see no way to pass in an OsStr as an argument to a shell function.

The big benefit I see to the current way is that it allows a shell function to take any type that is Display, which is certainly a nice property to have. But it also prevents you from passing in values that are not valid UTF-8.

The best option that I see would be to add an osstr option, e.g.

#[shell(osstr)]

to change the requirement of the arguments to be AsRef<OsStr> instead of ToString. (Maybe per field would be better.)

The alternative I see would be to define a new trait for this case, but that's inconvenient without trait specialization.

Thoughts?