From 5a725f9651f5a533f8cbf799eb816fdcffd62ca5 Mon Sep 17 00:00:00 2001 From: Chris Gillespie <6572184+gillespiecd@users.noreply.github.com> Date: Sun, 6 Sep 2020 09:36:50 -0700 Subject: [PATCH] Num links added to ls -l output (#2496) --- crates/nu-cli/src/shell/filesystem_shell.rs | 17 +++++++++++++++-- crates/nu-cli/tests/commands/ls.rs | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/crates/nu-cli/src/shell/filesystem_shell.rs b/crates/nu-cli/src/shell/filesystem_shell.rs index 98f825fd09..0d1a41068a 100644 --- a/crates/nu-cli/src/shell/filesystem_shell.rs +++ b/crates/nu-cli/src/shell/filesystem_shell.rs @@ -874,8 +874,18 @@ pub(crate) fn dir_entry_dict( #[cfg(unix)] { for column in [ - "name", "type", "target", "readonly", "mode", "uid", "group", "size", "created", - "accessed", "modified", + "name", + "type", + "target", + "num_links", + "readonly", + "mode", + "uid", + "group", + "size", + "created", + "accessed", + "modified", ] .iter() { @@ -942,6 +952,9 @@ pub(crate) fn dir_entry_dict( UntaggedValue::string(umask::Mode::from(mode).to_string()), ); + let nlinks = md.nlink(); + dict.insert_untagged("num_links", UntaggedValue::string(nlinks.to_string())); + if let Some(user) = users::get_user_by_uid(md.uid()) { dict.insert_untagged( "uid", diff --git a/crates/nu-cli/tests/commands/ls.rs b/crates/nu-cli/tests/commands/ls.rs index 94829aa2ef..fddf34554d 100644 --- a/crates/nu-cli/tests/commands/ls.rs +++ b/crates/nu-cli/tests/commands/ls.rs @@ -279,8 +279,18 @@ fn list_all_columns() { #[cfg(unix)] { [ - "name", "type", "target", "readonly", "mode", "uid", "group", "size", - "created", "accessed", "modified", + "name", + "type", + "target", + "num_links", + "readonly", + "mode", + "uid", + "group", + "size", + "created", + "accessed", + "modified", ] .join("") }