Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001606 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Objection Clarification Requested 2022-09-23 23:11 2022-11-01 15:20
Reporter Clausecker View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Applied  
Name Robert Clausecker
Organization Zuse Institute Berlin
User Reference
Section find
Page Number 2761
Line Number 90456–90458
Interp Status ---
Final Accepted Text Note: 0006009
Summary 0001606: find: is a directory loop considered to be an error?
Description The 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 Action Please 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.
Tags tc3-2008
Attached Files

- Relationships

-  Notes
(0005974)
geoffclare (manager)
2022-09-26 10:54

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.
(0006009)
geoffclare (manager)
2022-10-20 16:09

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 => Note: 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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker