Skip to content

std::process::Command should probably implement Display #72009

@matklad

Description

@matklad

At the moment, Command does not implement Display. However, it's often useful to display Command for the end user, the most common case being that the command failed, and you want to display an error message. If cmd.to_string() returned something like cargo --metadata --manifest-path ./foo/Cargo.toml, that would be sweet.

It's also instructive to compare it with Paths. Path deliberately doesn't implement display directly, and the reason for that (I think) is not to make people thing about non-text path when displaing paths, but to make it harder to miss-use string formatting for path operations. IE, we don't want to people doing

let path = PathBuf::from(format!("{}/{}", base, name))

, as that doesn't handle bag-of-bytes paths.

For Command, I don't think to_string() can be missused in a similar manner, so adding Display seems like a clear win to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-processArea: `std::process` and `std::env`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions