forked from extern/nushell
* Improve #4975 of filtering `ls` output by size issue * cargo fmt
This commit is contained in:
parent
8030f7e9f0
commit
8ffffe9bcc
@ -449,6 +449,11 @@ pub(crate) fn dir_entry_dict(
|
|||||||
|
|
||||||
cols.push("size".to_string());
|
cols.push("size".to_string());
|
||||||
if let Some(md) = metadata {
|
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 md.is_dir() {
|
||||||
if du {
|
if du {
|
||||||
let params = DirBuilder::new(Span { start: 0, end: 2 }, None, false, None, false);
|
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));
|
vals.push(Value::nothing(span));
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
vals.push(Value::nothing(span));
|
vals.push(Value::nothing(span));
|
||||||
|
Loading…
Reference in New Issue
Block a user