mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 05:27:45 +00:00
Merge pull request #5144 from Skryptonyte/stat_hyphen_fix
stat: Output error when - and -f are used together.
This commit is contained in:
commit
a8b6e500d4
2 changed files with 17 additions and 1 deletions
|
@ -614,6 +614,10 @@ impl Stater {
|
||||||
fn do_stat(&self, file: &OsStr, stdin_is_fifo: bool) -> i32 {
|
fn do_stat(&self, file: &OsStr, stdin_is_fifo: bool) -> i32 {
|
||||||
let display_name = file.to_string_lossy();
|
let display_name = file.to_string_lossy();
|
||||||
let file = if cfg!(unix) && display_name == "-" {
|
let file = if cfg!(unix) && display_name == "-" {
|
||||||
|
if self.show_fs {
|
||||||
|
show_error!("using '-' to denote standard input does not work in file system mode");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if let Ok(p) = Path::new("/dev/stdin").canonicalize() {
|
if let Ok(p) = Path::new("/dev/stdin").canonicalize() {
|
||||||
p.into_os_string()
|
p.into_os_string()
|
||||||
} else {
|
} else {
|
||||||
|
@ -622,7 +626,6 @@ impl Stater {
|
||||||
} else {
|
} else {
|
||||||
OsString::from(file)
|
OsString::from(file)
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.show_fs {
|
if self.show_fs {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
let p = file.as_bytes();
|
let p = file.as_bytes();
|
||||||
|
|
|
@ -304,6 +304,19 @@ fn test_stdin_pipe_fifo2() {
|
||||||
.succeeded();
|
.succeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(all(unix, not(target_os = "android")))]
|
||||||
|
fn test_stdin_with_fs_option() {
|
||||||
|
// $ stat -f -
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("-f")
|
||||||
|
.arg("-")
|
||||||
|
.set_stdin(std::process::Stdio::null())
|
||||||
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
|
.stderr_contains("using '-' to denote standard input does not work in file system mode");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
unix,
|
unix,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue