Merge pull request #2308 from uutils/revert-2305-rmdir-match-gnu-error

Revert "rmdir: match GNU error output"
This commit is contained in:
Sylvestre Ledru 2021-05-30 09:55:28 +02:00 committed by GitHub
commit 4d51e16140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 23 deletions

View file

@ -20,8 +20,6 @@ static OPT_VERBOSE: &str = "verbose";
static ARG_DIRS: &str = "dirs";
static ENOTDIR: i32 = 20;
fn get_usage() -> String {
format!("{0} [OPTION]... DIRECTORY...", executable!())
}
@ -107,11 +105,6 @@ fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Resu
fn remove_dir(path: &Path, ignore: bool, verbose: bool) -> Result<(), i32> {
let mut read_dir = match fs::read_dir(path) {
Ok(m) => m,
Err(e) if e.raw_os_error() == Some(ENOTDIR) => {
// To match the GNU output
show_error!("failed to remove '{}': Not a directory", path.display());
return Err(1);
}
Err(e) => {
show_error!("reading directory '{}': {}", path.display(), e);
return Err(1);

View file

@ -108,19 +108,3 @@ fn test_rmdir_ignore_nonempty_directory_with_parents() {
assert!(at.dir_exists(dir));
}
#[test]
fn test_rmdir_remove_symlink_match_gnu_error() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "file";
let fl = "fl";
at.touch(file);
assert!(at.file_exists(file));
at.symlink_file(file, fl);
assert!(at.file_exists(fl));
ucmd.arg("fl/")
.fails()
.stderr_is("rmdir: failed to remove 'fl/': Not a directory");
}