File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -840,9 +840,14 @@ impl Config {
840
840
match parse_size_u64 ( & raw_block_size. to_string_lossy ( ) ) {
841
841
Ok ( size) => Some ( size) ,
842
842
Err ( _) => {
843
- return Err ( Box :: new ( LsError :: BlockSizeParseError (
844
- opt_block_size. unwrap ( ) . clone ( ) ,
845
- ) ) ) ;
843
+ // only fail if invalid block size was specified with --block-size,
844
+ // ignore invalid block size from env vars
845
+ if let Some ( invalid_block_size) = opt_block_size {
846
+ return Err ( Box :: new ( LsError :: BlockSizeParseError (
847
+ invalid_block_size. clone ( ) ,
848
+ ) ) ) ;
849
+ }
850
+ None
846
851
}
847
852
}
848
853
} else if env_var_posixly_correct. is_some ( ) {
Original file line number Diff line number Diff line change @@ -3874,6 +3874,14 @@ fn test_ls_invalid_block_size() {
3874
3874
. stderr_is ( "ls: invalid --block-size argument 'invalid'\n " ) ;
3875
3875
}
3876
3876
3877
+ // TODO ensure the correct block size is used when using -l because
3878
+ // the output of "ls -l" and "BLOCK_SIZE=invalid ls -l" is different
3879
+ #[ test]
3880
+ fn test_ls_invalid_block_size_in_env_var ( ) {
3881
+ new_ucmd ! ( ) . env ( "LS_BLOCK_SIZE" , "invalid" ) . succeeds ( ) ;
3882
+ new_ucmd ! ( ) . env ( "BLOCK_SIZE" , "invalid" ) . succeeds ( ) ;
3883
+ }
3884
+
3877
3885
#[ cfg( all( unix, feature = "dd" ) ) ]
3878
3886
#[ test]
3879
3887
fn test_ls_block_size_override ( ) {
You can’t perform that action at this time.
0 commit comments