+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ impl<'a> Input<'a> {
};
#[cfg(unix)]
let mut src = Source::stdin_as_file();
#[cfg(unix)]
if let Source::StdinFile(f) = &src {
// GNU compatibility:
// this will check whether stdin points to a folder or not
if f.metadata()?.is_file() && settings.iflags.directory {
show_error!("standard input: not a directory");
return Err(1.into());
}
};
if settings.skip > 0 {
src.skip(settings.skip)?;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/by-util/test_dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,20 @@ fn test_reading_partial_blocks_from_fifo_unbuffered() {
assert!(output.stderr.starts_with(expected));
}

#[test]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn test_iflag_directory_fails_when_file_is_passed_via_std_in() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.make_file("input");
let filename = at.plus_as_string("input");
new_ucmd!()
.args(&["iflag=directory", "count=0"])
.set_stdin(std::process::Stdio::from(File::open(filename).unwrap()))
.fails()
.stderr_contains("standard input: not a directory");
}

#[test]
fn test_stdin_stdout_not_rewound_even_when_connected_to_seekable_file() {
use std::process::Stdio;
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载