coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

ls: `-L` on broken links should return 1

Open jtracey opened this issue 3 years ago • 5 comments

ls is supposed to have an exit status of 1 for "minor problems". This includes trying to dereference symbolic links (via -L) when they don't link anywhere. The lack of return code is causing the latest tests/ls/selinux-segfault GNU test to fail.

jtracey avatar Jan 27 '22 18:01 jtracey

The call that should return 1, according to the GNU test, is specifically:

ls -L -Z

We already return 1 with:

ls -L -l

Or any other case where we try to deference the a broken symlink. I believe (but am not sure) that the issue is that because the security context is not supported in the first place, we never get the metadata, so we don't show the error.

tertsdiepraam avatar Jan 27 '22 23:01 tertsdiepraam

ls seems like it needs a meta-thread for its issues. Is OP implementing this?

kimono-koans avatar Jan 28 '22 15:01 kimono-koans

sure, please open as many issues as you need :)

sylvestre avatar Jan 28 '22 16:01 sylvestre

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 28 '23 20:01 stale[bot]

This is still an issue.

We already return 1 with: ls -L -l Or any other case where we try to deference the a broken symlink.

I'm still seeing ret code 0 with just ls -L for us, and ret code 1 on GNU.

jtracey avatar Jan 30 '23 04:01 jtracey

I've looked into it and think I've solved the ls -L -Z issue.

Though with GNU coreutils 9.1, I see ls -L returns 0, which is aligned with the behaviour I see in uutils ?

granquet avatar Jun 08 '23 10:06 granquet

uutils ls -L is returning 0 for me. Which case is incompatible exactly?

tertsdiepraam avatar Jun 08 '23 10:06 tertsdiepraam

ls -L -Z

  • returns 0 in uutils
  • returns 1 in GNU coreutils Attempting to fix this case with : https://github.com/uutils/coreutils/pull/4960

ls -L returns 0 on both, @jtracey seemed to imply that ls -L should return 1 too?

granquet avatar Jun 08 '23 12:06 granquet

Ah sorry, I misread your comment. I think you're right!

tertsdiepraam avatar Jun 08 '23 12:06 tertsdiepraam

Fixed in https://github.com/uutils/coreutils/pull/4960

cakebaker avatar Jul 01 '23 13:07 cakebaker