1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 12:37:49 +00:00

Added support to read a filename redirected to stdin

- Canonicalization of `/dev/stdin` which points to stdin file
This commit is contained in:
Kartik Sharma 2022-03-20 17:57:00 +05:30
parent ad237f8fff
commit 71a6ae1443

View file

@ -471,11 +471,18 @@ impl Stater {
} }
fn new(matches: &ArgMatches) -> UResult<Self> { fn new(matches: &ArgMatches) -> UResult<Self> {
let files: Vec<String> = matches let mut files: Vec<String> = matches
.values_of(ARG_FILES) .values_of(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect()) .map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default(); .unwrap_or_default();
#[cfg(unix)]
if files.contains(&String::from("-")) {
files = Vec::from([Path::new("/dev/stdin")
.canonicalize()?
.into_os_string()
.into_string()
.unwrap()]);
}
let format_str = if matches.is_present(options::PRINTF) { let format_str = if matches.is_present(options::PRINTF) {
matches matches
.value_of(options::PRINTF) .value_of(options::PRINTF)