[bug #66135] loop: different error messages describe an identical (?) error

Jean-Baptiste de la Tour <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
URL:
  <https://savannah.gnu.org/bugs/?66135>

                 Summary: loop: different error messages describe an identical
(?) error
                   Group: findutils
               Submitter: jbdlt
               Submitted: Wed 28 Aug 2024 01:33:40 PM UTC
                Category: find
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.10.0
           Fixed Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 28 Aug 2024 01:33:40 PM UTC By: Jean-Baptiste de la Tour <jbdlt>
== The issue ==

In case of loops, *find* prints a different error message depending on if a
loop includes:
* either: only symbolic links
* or: at least one directory
     
length = 1:

$ ln -s link link
$ find -L -xtype l
find: ‘./link’: Too many levels of symbolic links
$ 


length = 2 / two symbolic links:

$ ln -s symb link
$ ln -s link symb
$ find -L -xtype l
find: ‘./link’: Too many levels of symbolic links
find: ‘./symb’: Too many levels of symbolic links
$ 


length = 2 / one symbolic link and one directory:

$ ln -s . link
$ find -L -xtype l
find: File system loop detected; ‘./link’ is part of the same file system
loop as ‘.’.
$ 


Having two different error messages implies that *find* somehow interprets
these loops differently (and that the user _must know_ the difference and
_must adjust_ their command line consequently).

If *find* _does_ process these loops differently (meaning: *find* requires an
adjustement on the command line (input), or will produce a different result
(output) in some specific cases), then it should be explained in the
[https://www.gnu.org/software/findutils/manual/html_node/find_html/Symbolic-Links.html
GNU Findutils manual in section "2.4.1 Symbolic Links"] where the only
reference on this subject (explaining that both are treated identically) is:
* "This also occurs if a symbolic link exists but points to a file that is
missing [broken link], or where _the symbolic link points to itself [loop]
(directly or indirectly)_."

If *find* processes these loops identically, then there should be only one
type of error message. The message _"File system loop detected […]"_ should
be chosen, being more useful due to:
* properly explaining that it is an actual _loop_ and not simply a number of
links (not forming a loop) exceeding some hard-coded maximum level of
indirection
* providing the start and the end of the loop

This difference or equality of treatment should also be referred to in section
[https://www.gnu.org/software/findutils/manual/html_node/find_html/Error-Messages-From-find.html
12.1 Error Messages From find].

This may not seem important, however:
* If the user *grep*-s the standard error of *find* to filter some error
messages
([https://stackoverflow.com/questions/762348/how-can-i-exclude-all-permission-denied-messages-from-find#762360
see this example]), two different error messages for one error is, for the
user, more work for nothing more to gain.
* When testing some options of *find*, it is more work to assert that
_link-to-link_ loops and _link-to-directory-to-link_ loops produce an
identical result (these extracts above are from my own personal test trying to
understand "-L -xtype l" depending on {broken | link-to-self | link-to-link |
link-to-directory-to-link | normal}).
* It may have an impact on bug reporting. (see below)
* It may have an impact on web searches: requesting help using one error
message might not result in a solution provided by a forum to the same problem
but raised by another error message.

== Concrete case of bug reporting ==

According to bug #65831, the following example is a bug concerning
_link-to-link_ loops:

$ ln -s link link
$ find -L -type l
find: ‘./link’: Too many levels of symbolic links
$ echo $?
1
$ 


I quote: "The exit status is 1. Nothing is printed on stdout."

But this bug says nothing on this following _link-to-directory-to-link_ loop:

$ ln -s . link
$ find -L -type l
find: File system loop detected; ‘./link’ is part of the same file system
loop as ‘.’.
$ echo $?
1
$ 


Same result: The exist status is 1. Nothing is printed on stdout.

However, the error message is _different_. Should it be considered a variation
of the same bug, or should a different bug report be filed? A user who does
not know that both error messages are the same error (after all, they are not
even documented on the
[https://www.gnu.org/software/findutils/manual/html_node/find_html/Error-Messages-From-find.html
12.1 Error Messages From find]), and even going the extra mile of checking
that their bug has not already been reported, may not find the previous bug
due to the error message being different.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66135>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCZs8nOQAKCRCqLAuaBUf3
TqX2AQCsMxSt1Y9PerZvtEXNl+3PUlT/q/ZcCIRsXOkwvcqNngD/UTcfVXoRRgga
W3jOhuOYOom3mmJ6dym3+eDevsrwdQI=
=eGE2
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.