Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2830,8 +2830,10 @@ fn display_item_long(
output_display.extend(b".");
} else if is_acl_set {
output_display.extend(b"+");
} else {
output_display.extend(b" ");
}
output_display.extend(b" ");

output_display.extend_pad_left(&display_symlink_count(md), padding.link_count);

if config.long.owner {
Expand Down Expand Up @@ -3486,6 +3488,19 @@ fn calculate_padding_collection(
if config.context {
padding_collections.context = context_len.max(padding_collections.context);
}

// correctly align columns when some files have capabilities/ACLs and others do not
{
#[cfg(any(not(unix), target_os = "android", target_os = "macos"))]
// TODO: See how Mac should work here
let is_acl_set = false;
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
let is_acl_set = has_acl(item.display_name());
if context_len > 1 || is_acl_set {
padding_collections.link_count += 1;
}
}

if items.len() == 1usize {
padding_collections.size = 0usize;
padding_collections.major = 0usize;
Expand Down
23 changes: 20 additions & 3 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6139,7 +6139,9 @@ fn test_unknown_format_specifier() {
fn test_acl_display_symlink() {
use std::process::Command;

let (at, mut ucmd) = at_and_ucmd!();
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;

let dir_name = "dir";
let link_name = "link";
at.mkdir(dir_name);
Expand All @@ -6164,11 +6166,26 @@ fn test_acl_display_symlink() {

at.symlink_dir(dir_name, link_name);

let re_with_acl = Regex::new(r"[a-z-]*\+ .*link").unwrap();
ucmd.arg("-lLd")
let re_with_acl = Regex::new(r"[a-z-]*\+\s\d+\s.*link").unwrap();

scene
.ucmd()
.arg("-lLd")
.arg(link_name)
.succeeds()
.stdout_matches(&re_with_acl);

let test2: uutests::util::CmdResult = scene.ucmd().arg("-l").succeeds();

let mut iter = test2
.stdout()
.split(|b| b == &b'\n')
.skip(1)
.filter_map(|line: &[u8]| line.iter().position(|b: &u8| b.is_ascii_digit()));

let first = iter.next().unwrap();

assert!(iter.all(|i| i == first));
}

#[test]
Expand Down
Loading