summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uu/ls/src/ls.rs9
-rw-r--r--tests/by-util/test_ls.rs10
2 files changed, 14 insertions, 5 deletions
diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs
index 4feb70db7..3b34cf15e 100644
--- a/src/uu/ls/src/ls.rs
+++ b/src/uu/ls/src/ls.rs
@@ -183,7 +183,7 @@ impl UError for LsError {
Self::IOError(_) => 1,
Self::IOErrorContext(_, _, false) => 1,
Self::IOErrorContext(_, _, true) => 2,
- Self::BlockSizeParseError(_) => 1,
+ Self::BlockSizeParseError(_) => 2,
Self::ConflictingArgumentDired => 1,
Self::DiredAndZeroAreIncompatible => 2,
Self::AlreadyListedError(_) => 2,
@@ -809,10 +809,9 @@ impl Config {
match parse_size_u64(&raw_block_size.to_string_lossy()) {
Ok(size) => Some(size),
Err(_) => {
- show!(LsError::BlockSizeParseError(
- opt_block_size.unwrap().clone()
- ));
- None
+ return Err(Box::new(LsError::BlockSizeParseError(
+ opt_block_size.unwrap().clone(),
+ )));
}
}
} else if env_var_posixly_correct.is_some() {
diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs
index 0e817511f..c9f43028c 100644
--- a/tests/by-util/test_ls.rs
+++ b/tests/by-util/test_ls.rs
@@ -3865,6 +3865,16 @@ fn test_posixly_correct() {
}
#[test]
+fn test_ls_invalid_block_size() {
+ new_ucmd!()
+ .arg("--block-size=invalid")
+ .fails()
+ .code_is(2)
+ .no_stdout()
+ .stderr_is("ls: invalid --block-size argument 'invalid'\n");
+}
+
+#[test]
fn test_ls_hyperlink() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;