mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #5674 from cakebaker/ls_ignore_invalid_block_size_from_env_vars
ls: ignore invalid block size from env vars
This commit is contained in:
commit
3d42619027
2 changed files with 16 additions and 3 deletions
|
@ -840,10 +840,15 @@ impl Config {
|
||||||
match parse_size_u64(&raw_block_size.to_string_lossy()) {
|
match parse_size_u64(&raw_block_size.to_string_lossy()) {
|
||||||
Ok(size) => Some(size),
|
Ok(size) => Some(size),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
// only fail if invalid block size was specified with --block-size,
|
||||||
|
// ignore invalid block size from env vars
|
||||||
|
if let Some(invalid_block_size) = opt_block_size {
|
||||||
return Err(Box::new(LsError::BlockSizeParseError(
|
return Err(Box::new(LsError::BlockSizeParseError(
|
||||||
opt_block_size.unwrap().clone(),
|
invalid_block_size.clone(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if env_var_posixly_correct.is_some() {
|
} else if env_var_posixly_correct.is_some() {
|
||||||
Some(POSIXLY_CORRECT_BLOCK_SIZE)
|
Some(POSIXLY_CORRECT_BLOCK_SIZE)
|
||||||
|
|
|
@ -3874,6 +3874,14 @@ fn test_ls_invalid_block_size() {
|
||||||
.stderr_is("ls: invalid --block-size argument 'invalid'\n");
|
.stderr_is("ls: invalid --block-size argument 'invalid'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO ensure the correct block size is used when using -l because
|
||||||
|
// the output of "ls -l" and "BLOCK_SIZE=invalid ls -l" is different
|
||||||
|
#[test]
|
||||||
|
fn test_ls_invalid_block_size_in_env_var() {
|
||||||
|
new_ucmd!().env("LS_BLOCK_SIZE", "invalid").succeeds();
|
||||||
|
new_ucmd!().env("BLOCK_SIZE", "invalid").succeeds();
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(all(unix, feature = "dd"))]
|
#[cfg(all(unix, feature = "dd"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ls_block_size_override() {
|
fn test_ls_block_size_override() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue