1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

Merge branch 'main' into dependabot/cargo/strum_macros-0.24.1

This commit is contained in:
Sylvestre Ledru 2022-06-13 16:01:46 +02:00 committed by GitHub
commit a07f331665
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 7 deletions

4
Cargo.lock generated
View file

@ -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"

View file

@ -569,10 +569,20 @@ impl Config {
};
let width = match options.value_of(options::WIDTH) {
Some(x) => match x.parse::<u16>() {
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::<u16>() {
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") {

View file

@ -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" }

View file

@ -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::<Vec<_>>())
.arg("-C")
.succeeds()
.stdout_only("test-width-1 test-width-3\ntest-width-2 test-width-4\n");
}
scene
.ucmd()
.arg("-w=bad")