View Issue Details

IDProjectCategoryView StatusLast Update
00016061003.1(2016/18)/Issue7+TC2Shell and Utilitiespublic2024-06-11 09:07
ReporterClausecker Assigned To 
PrioritynormalSeverityObjectionTypeClarification Requested
Status ClosedResolutionAccepted As Marked 
NameRobert Clausecker
OrganizationZuse Institute Berlin
User Reference
Sectionfind
Page Number2761
Line Number90456–90458
Interp Status---
Final Accepted Text0001606:0006009
Summary0001606: find: is a directory loop considered to be an error?
DescriptionThe find(1) utility is specified to print a diagnostic message upon encountering a directory loop:

> The find utility shall detect infinite loops; that is, entering
> a previously visited directory that is an ancestor of the last file
> encountered. When it detects an infinite loop, find shall write
> a diagnostic message to standard error and shall either recover
> its position in the hierarchy or terminate.

What is not specified is if the find(1) utility shall consider this to be an error and return a non-zero exit status. While the Utility Description Defaults seem to indicate that a non-zero exit status shall be returned for any diagnostic message printed, it is not entirely clear if this applies to this case.

GNU find and SunOS find do. FreeBSD find(1) and Jörg Schilling's libfind/sfind neither print a diagnostic message nor return a non-zero exit status.

This situation most commonly occurs when operating with -L and a symbolic link to a directory up the hierarchy is encountered. Such cases seem to be benign and can easily be backed out of. Other cases (e.g. a true directory loop through misuse of hard links) may indicate a problem in the file system. It may be convenient for the user to search through symbolically linked directory hierarchies without the search failing through a case that doesn't really affect the search.

See also https://codeberg.org/schilytools/schilytools/issues/27
Desired ActionPlease clarify if the find(1) utility is meant to consider a directory loop to be an error condition causing exit with a nonzero exit status. If it is intended to specify if it is, please add appropriate language, e.g.

> When it detects an infinite loop, find shall write
> a diagnostic message to standard error and shall either recover
> its position in the hierarchy or terminate. In either case,
> the exit status shall be nonzero.

If it is intended that the implementation is free to consider this to be an error condition or not, please add appropriate language to RATIONALE indicating that this.
Tagstc3-2008

Activities

geoffclare

2022-09-26 10:54

manager   bugnote:0005974

Since find is not allowed to write to standard error (except for the -ok prompt) when its exit status is zero, the requirement to write to standard error when an infinite loop is detected automatically brings with it a requirement that the exit status be nonzero.

See XCU 1.4 Utility Description Defaults -> STDERR -> Default Behavior.

However, it would make sense to state this explicitly, along the lines suggested in the desired action.

geoffclare

2022-10-20 16:09

manager   bugnote:0006009

After:
When it detects an infinite loop, find shall write a diagnostic message to standard error and shall either recover its position in the hierarchy or terminate.
add a new sentence:
In either case, the final exit status shall be non-zero.

Issue History

Date Modified Username Field Change
2022-09-23 23:11 Clausecker New Issue
2022-09-23 23:11 Clausecker Name => Robert Clausecker
2022-09-23 23:11 Clausecker Organization => Zuse Institute Berlin
2022-09-23 23:11 Clausecker Section => find
2022-09-23 23:11 Clausecker Page Number => 2761
2022-09-23 23:11 Clausecker Line Number => 90456–90458
2022-09-26 10:54 geoffclare Note Added: 0005974
2022-10-20 16:09 geoffclare Note Added: 0006009
2022-10-20 16:10 geoffclare Interp Status => ---
2022-10-20 16:10 geoffclare Final Accepted Text => 0001606:0006009
2022-10-20 16:10 geoffclare Status New => Resolved
2022-10-20 16:10 geoffclare Resolution Open => Accepted As Marked
2022-10-20 16:10 geoffclare Tag Attached: tc3-2008
2022-11-01 15:20 geoffclare Status Resolved => Applied
2024-06-11 09:07 agadmin Status Applied => Closed