coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Fix ls: panicking on dangling symlink with ``--color=auto -l``

Open AnirbanHalder654322 opened this issue 1 year ago • 7 comments

fixes #6227

The get_metadata() function seemed to try to deference to the non existent file. We change it to directly get the metadata of the symlink itself incase the deference fails.

AnirbanHalder654322 avatar May 04 '24 17:05 AnirbanHalder654322

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar May 04 '24 18:05 github-actions[bot]

Changes since last push :

  • Changed the logic to use
        let md_res = get_metadata_with_deref_opt(target.p_buf.as_path(), path.must_dereference);
        let md = md_res.or(target.p_buf.symlink_metadata());

        apply_style_based_on_metadata(path, md.as_ref(),ok(), ls_colors, style_manager, &name)
  • Added test

AnirbanHalder654322 avatar May 07 '24 07:05 AnirbanHalder654322

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar May 07 '24 08:05 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar May 07 '24 10:05 github-actions[bot]

Changes since last push:

  • Using at.symlink_file for symlink creation
  • Switched to regex matching for extracting colors from stdout
  • Squashed the commit into an older comment formatting commit to clean up history .

AnirbanHalder654322 avatar May 09 '24 12:05 AnirbanHalder654322

I was wondering if i should clean up the commit history a bit more ? Maybe only leave two commits one for the main change and another for the test ?

AnirbanHalder654322 avatar May 09 '24 16:05 AnirbanHalder654322

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar May 09 '24 17:05 github-actions[bot]