Skip to content
Closed
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
1 change: 1 addition & 0 deletions src/uu/ls/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ls-error-unknown-io-error = unknown io error: {$path}, '{$error}'
ls-error-invalid-block-size = invalid --block-size argument {$size}
ls-error-dired-and-zero-incompatible = --dired and --zero are incompatible
ls-error-not-listing-already-listed = {$path}: not listing already-listed directory
ls-error-not-directory = {$path}: A path component was not a directory
ls-error-invalid-time-style = invalid --time-style argument {$style}
Possible values are:
- [posix-]full-iso
Expand Down
1 change: 1 addition & 0 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ enum LsError {

#[error("{}", match .1.kind() {
ErrorKind::NotFound => translate!("ls-error-cannot-access-no-such-file", "path" => .0.quote()),
ErrorKind::NotADirectory => translate!("ls-error-not-directory", "path" => .0.quote()),
ErrorKind::PermissionDenied => match .1.raw_os_error().unwrap_or(1) {
1 => translate!("ls-error-cannot-access-operation-not-permitted", "path" => .0.quote()),
_ => if .0.is_dir() {
Expand Down
12 changes: 12 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,18 @@ fn test_ls_non_existing() {
new_ucmd!().arg("doesntexist").fails();
}

#[test]
#[cfg(unix)]
fn test_ls_not_a_directory_errors() {
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.arg("/etc/hosts/test")
.fails()
.code_is(2)
.stderr_contains("not a directory");
}

#[test]
fn test_ls_files_dirs() {
let scene = TestScenario::new(util_name!());
Expand Down
Loading