Skip to content

ls -lF symlink target indicators#11554

Open
joknarf wants to merge 1 commit intouutils:mainfrom
joknarf:classify_target
Open

ls -lF symlink target indicators#11554
joknarf wants to merge 1 commit intouutils:mainfrom
joknarf:classify_target

Conversation

@joknarf
Copy link
Copy Markdown

@joknarf joknarf commented Mar 30, 2026

Fixes #11542
gnu output incompatibility with --classify on symlink targets

before:

 • ls -lF mylink*
lrwxrwxrwx 1 user group 5 Nov 22 08:33 mylinktodir@ -> mydir
lrwxrwxrwx 1 user group 9 Nov 22 08:31 mylinktoexe@ -> myexec.sh
lrwxrwxrwx 1 user group 6 Nov 22 08:34 mylinktofile@ -> myfile
lrwxrwxrwx 1 user group 6 Nov 22 08:47 mylinktopipe@ -> mypipe
lrwxrwxrwx 1 user group 6 Mar 29 10:42 mylinktosock@ -> mysock

after (gnu identical output):

 • gnuls -lF mylink*
lrwxrwxrwx 1 user group 5 Nov 22 09:33 mylinktodir -> mydir/
lrwxrwxrwx 1 user group 9 Nov 22 09:31 mylinktoexe -> myexec.sh*
lrwxrwxrwx 1 user group 6 Nov 22 09:34 mylinktofile -> myfile
lrwxrwxrwx 1 user group 6 Nov 22 09:47 mylinktopipe -> mypipe|
lrwxrwxrwx 1 user group 6 Mar 29 10:42 mylinktosock -> mysock=

Copy link
Copy Markdown
Contributor

@Alonely0 Alonely0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, but there are a lot of removed comments (vibecode?) and unnecessary performance hits.

}

fn indicator_char(path: &PathData, style: IndicatorStyle) -> Option<char> {
let sym = classify_file(path);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classify_files() function is now called unconditionally, but beforehand it was contingent on config.indicator_style != IndicatorStyle::None. I'm concerned this is going to negatively affect performance since it has to stat files. Maybe the best solution is to remove the IndicatorStyle::None branch and change all occurrences of IndicatorStyle to Option<IndicatorStyle>, then do a let-else.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PD: please keep the old comments on the code you refactored to this new function. Did you vibecode this? Don't take it the wrong way; this is just a usual telltale.

None => target_path.clone(),
}
} else {
target_path.clone()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not clone here; it is not necessary. Use references, like the previous code that you have replaced. This was fixed in edfe26c.

),
);
} else {
name.push(escaped_target);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep comments. Previously in L804-805.

false,
);

let mut target_display = escaped_target.clone();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not clone here. You should refactor the immediate assignment inside the if to be the expression of the let definition, like let var = if ... { ... } else { ... };. Alternatively, use references or a Cow if you have to.

false,
);

// Check if the target actually needs coloring
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this comment if you can.

);

if style.is_some() {
// Only apply coloring if there's actually a style
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this comment if you can.

is_wrap(name.len()),
));
} else {
// For regular files with no coloring, just use plain text
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once/if you apply the other requested changes, consider keeping this comment.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/seq/seq-epipe is now passing!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 31, 2026

Merging this PR will degrade performance by 4.83%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 3 regressed benchmarks
✅ 300 untouched benchmarks
⏩ 46 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ls_recursive_balanced_tree[(6, 4, 15)] 51.9 ms 54.3 ms -4.37%
Simulation ls_recursive_deep_tree[(200, 2)] 1.7 ms 1.8 ms -4.83%
Simulation ls_recursive_wide_tree[(10000, 1000)] 36 ms 37.7 ms -4.34%
Simulation cp_large_file[16] 279.5 µs 264.9 µs +5.51%

Comparing joknarf:classify_target (c9b81dc) with main (236e220)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sylvestre
Copy link
Copy Markdown
Contributor

please fix the failing tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ls -lF (--classify) symlink target indicator missing

3 participants