Bug 15466 - 'realpath -- /tmp' non-compliant with upcoming POSIX
Summary: 'realpath -- /tmp' non-compliant with upcoming POSIX
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.35.x
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-21 17:06 UTC by Eric Blake
Modified: 2023-03-23 14:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
readlink: Support --, -n always (2.97 KB, patch)
2023-03-23 14:07 UTC, Eric Blake
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Blake 2023-03-21 17:06:05 UTC
POSIX will be standardizing realpath in Issue 8:
https://www.austingroupbugs.net/view.php?id=1457

As such, the standard requirements that all utilities not explicitly excluded (basically, echo is one of the few explicit exceptions) MUST accept -- as end-of-options, even when the standard does not require any standardized options.  Once Issue 8 is out,

realpath /tmp
realpath -- /tmp

must have identical behavior.  Busybox 1.35 (I tested the pre-built version available on Fedora 37) fails this:

$ busybox realpath -- /tmp
realpath: --: No such file or directory
/tmp
Comment 1 Eric Blake 2023-03-22 13:13:14 UTC
Similarly, POSIX still requires 'readlink -- /foo' and 'readlink /foo' to behave identically.  This is implemented correctly when FEATURE_READLINK_FOLLOW is enabled (as a side effect of accepting the POSIX-mandated -n), but fails when the feature is disabled (that branch of the code should probably use single_argv(), similarly to how coreutils/dirname.c was patched).
Comment 2 Eric Blake 2023-03-23 14:07:48 UTC
Created attachment 9561 [details]
readlink: Support --, -n always

Ugh - unlike many open-source projects, your mailing list does not allow moderated posting from non-subscribers. So while I wait for my subscription request to be processed, I'm attaching a partial proposed patch for readlink.

Originally, I thought to do a one-liner to use single_argv(); then realized that it was easier to blindly support -n in all configurations since POSIX will require -n support.  I'm still trying to learn whether POSIX or GNU Coreutils will prevail on whether readlink should be silent or verbose by default.