mirror of
https://github.com/nushell/nushell
synced 2024-11-10 23:24:14 +00:00
* Improve #4975 of filtering `ls` output by size issue * cargo fmt
This commit is contained in:
parent
8030f7e9f0
commit
8ffffe9bcc
1 changed files with 14 additions and 1 deletions
|
@ -449,6 +449,11 @@ pub(crate) fn dir_entry_dict(
|
|||
|
||||
cols.push("size".to_string());
|
||||
if let Some(md) = metadata {
|
||||
#[cfg(unix)]
|
||||
let zero_sized = md.file_type().is_socket()
|
||||
|| md.file_type().is_char_device()
|
||||
|| md.file_type().is_block_device();
|
||||
|
||||
if md.is_dir() {
|
||||
if du {
|
||||
let params = DirBuilder::new(Span { start: 0, end: 2 }, None, false, None, false);
|
||||
|
@ -481,7 +486,15 @@ pub(crate) fn dir_entry_dict(
|
|||
vals.push(Value::nothing(span));
|
||||
}
|
||||
} else {
|
||||
vals.push(Value::nothing(span));
|
||||
#[cfg(not(unix))]
|
||||
let value = Value::nothing(span);
|
||||
#[cfg(unix)]
|
||||
let value = if zero_sized {
|
||||
Value::Filesize { val: 0, span }
|
||||
} else {
|
||||
Value::nothing(span)
|
||||
};
|
||||
vals.push(value);
|
||||
}
|
||||
} else {
|
||||
vals.push(Value::nothing(span));
|
||||
|
|
Loading…
Reference in a new issue