diff --git a/Cargo.lock b/Cargo.lock index 37466ff34..c0b50f82d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1859,9 +1859,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96acfc1b70604b8b2f1ffa4c57e59176c7dbb05d556c71ecd2f5498a1dee7f8" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" [[package]] name = "strum_macros" diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index 2ebd2fb97..30255b442 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -569,10 +569,20 @@ impl Config { }; let width = match options.value_of(options::WIDTH) { - Some(x) => match x.parse::() { - Ok(u) => u, - Err(_) => return Err(LsError::InvalidLineWidth(x.into()).into()), - }, + Some(x) => { + if x.starts_with('0') && x.len() > 1 { + // Read number as octal + match u16::from_str_radix(x, 8) { + Ok(v) => v, + Err(_) => return Err(LsError::InvalidLineWidth(x.into()).into()), + } + } else { + match x.parse::() { + Ok(u) => u, + Err(_) => return Err(LsError::InvalidLineWidth(x.into()).into()), + } + } + } None => match termsize::get() { Some(size) => size.cols, None => match std::env::var_os("COLUMNS") { diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index c30acad43..118d3b4bf 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -16,7 +16,7 @@ path = "src/uniq.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -strum = "0.24.0" +strum = "0.24.1" strum_macros = "0.24.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index db2c3d445..739fe8b48 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -650,6 +650,21 @@ fn test_ls_width() { .stdout_only("test-width-1 test-width-2 test-width-3 test-width-4\n"); } + for option in [ + "-w 062", + "-w=062", + "--width=062", + "--width 062", + "--wid=062", + ] { + scene + .ucmd() + .args(&option.split(' ').collect::>()) + .arg("-C") + .succeeds() + .stdout_only("test-width-1 test-width-3\ntest-width-2 test-width-4\n"); + } + scene .ucmd() .arg("-w=bad")