mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
cp: fix cp-i
GNU test
`cp` in interactive mode used to write to stdout asking for overwrite. GNU version writes to stderr. Changed: write to stderr to make compatible with GNU.
This commit is contained in:
parent
2cddce26d3
commit
2ce999c959
2 changed files with 6 additions and 4 deletions
|
@ -35,7 +35,7 @@ use std::fs;
|
|||
use std::fs::File;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io;
|
||||
use std::io::{stdin, stdout, Write};
|
||||
use std::io::{stderr, stdin, Write};
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
#[cfg(unix)]
|
||||
|
@ -118,9 +118,9 @@ macro_rules! or_continue(
|
|||
/// answered yes.
|
||||
macro_rules! prompt_yes(
|
||||
($($args:tt)+) => ({
|
||||
print!($($args)+);
|
||||
print!(" [y/N]: ");
|
||||
crash_if_err!(1, stdout().flush());
|
||||
eprint!($($args)+);
|
||||
eprint!(" [y/N]: ");
|
||||
crash_if_err!(1, stderr().flush());
|
||||
let mut s = String::new();
|
||||
match stdin().read_line(&mut s) {
|
||||
Ok(_) => match s.char_indices().next() {
|
||||
|
|
|
@ -204,6 +204,8 @@ fn test_cp_arg_interactive() {
|
|||
.arg("-i")
|
||||
.pipe_in("N\n")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.stderr_contains(format!("overwrite '{}'?", TEST_HOW_ARE_YOU_SOURCE))
|
||||
.stderr_contains("Not overwriting");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue