Red Hat Bugzilla – Bug 525402
ls -L option Can not detects infinite loops
Last modified: 2009-10-12 07:26:56 EDT
Description of problem:
ls should exit with 1 when detects infinite loops.
This problem should be the same as -L option problem
After using -L option the link should show as the linked file/folder.
So it will be a infinite loop
Version-Release number of selected component (if applicable):
Steps to Reproduce:
ln -s $PWD/ls_73_dir $PWD/ls_73_dir/ls_73_dir2/ls_73_link
ls -RL ls_73_dir
$? = 0
$? = 1
and print some error message
This is a part of POSIX shell test from opengroup
Sorry, but almost works for me ... (version is the same)
$ls -RL ls_73_dir
ls: ls_73_dir/ls_73_dir2/ls_73_link: not listing already-listed directory
$? = 0, but this maybe considered as exit success - as all files were listed successfully and infinite loop was correctly detected. Will check if it does conform with POSIX...
What's the output on your side? Could you provide strace log (please, with C locales)? TIA.
My output is same with you.
The problem is test suite expect this it exit fail.
I'm not sure which behavior is right? If POSIX did not defined this situation I think our behavior(consider as exit success) should be ok.
If so I'll submit a problem to test suite.
And I'll attach my script and strace here later.
(In reply to comment #1)
> Sorry, but almost works for me ... (version is the same)
> $ls -RL ls_73_dir
> ls: ls_73_dir/ls_73_dir2/ls_73_link: not listing already-listed directory
> $? = 0, but this maybe considered as exit success - as all files were listed
> successfully and infinite loop was correctly detected. Will check if it does
> conform with POSIX...
> What's the output on your side? Could you provide strace log (please, with C
> locales)? TIA.
Created attachment 362487 [details]
Created attachment 362489 [details]
strace log with LC_ALL=C
I meant strace log of the ls command, not the shell scripts (it doesn't trace child processes), but it doesn't matter if the output is the same...
Yes, I think POSIX is not specific what to do in the case of infinite loop. Upstream decided to just exit 0 with information message. Please discuss the issue with authors of testsuite - and if they feel there is something in POSIX what requires nonzero exit status in that case, feel free to report it upstream at firstname.lastname@example.org - as this behaviour is not Fedora specific (and IMHO is correct - so closing NOTABUG this bugzilla). Mention this bugzilla in that case.
Anyway, thanks for report(s).
I think POSIX is quite clear. If an error is reported the exit code is > 0. The text requiring the detection of inifinite loops says a diagnostic is written but this term implies that there is a problem (aka error). Hence I think ls has to be changed.
Thanks for the report! I've just posted a patch:
coreutils 8.0 which contains that fix is now in rawhide, closing.