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
4 changes: 2 additions & 2 deletions src/find/matchers/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Ls {

match writeln!(
out,
" {:<4} {:>6} {:<10} {:>3} {:<8} {:<8} {:>8} {} {}",
"{:>9} {:>6} {:<10} {:>3} {:<8} {:<8} {:>8} {} {}",
inode_number,
number_of_blocks,
permission,
Expand Down Expand Up @@ -180,7 +180,7 @@ impl Ls {

match writeln!(
out,
" {:<4} {:>6} {:<10} {:>3} {:<8} {:<8} {:>8} {} {}",
"{:>9} {:>6} {:<10} {:>3} {:<8} {:<8} {:>8} {} {}",
inode_number,
number_of_blocks,
permission,
Expand Down
25 changes: 25 additions & 0 deletions tests/test_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,31 @@ fn find_ls_shows_allocated_blocks_and_link_target() {
.stdout_contains(" -> sparse\n");
}

#[test]
#[cfg(unix)]
fn find_ls_inode_column_is_right_aligned() {
use std::os::unix::fs::MetadataExt;

let temp_dir = Builder::new().prefix("find_ls_inode").tempdir().unwrap();
let file = temp_dir.path().join("plain");
File::create(&file).unwrap();

let metadata = fs::metadata(&file).unwrap();
// the inode number fills 9 columns, right-aligned, and starts the line
let expected = format!(
"{:>9} {:>6} ",
metadata.ino(),
metadata.blocks().div_ceil(2)
);

let result = ucmd().args(&[file.to_str().unwrap(), "-ls"]).succeeds();
assert!(
result.stdout_str().starts_with(&expected),
"{:?} does not start with {expected:?}",
result.stdout_str()
);
}

#[test]
#[cfg(unix)]
fn find_ls_shows_device_numbers() {
Expand Down
Loading