The realpath
command utility is now defined by POSIX in its issue 8 (2024): realpath — resolve a pathname
realpath [-E|-e] file
The realpath utility shall canonicalize the pathname specified by the file operand as follows:
If a call to the
realpath()
function with the specified pathname as its first argument would succeed, the canonicalized pathname shall be the pathname that would be returned by thatrealpath()
call. Otherwise:
If the -e option is specified, the canonicalization shall fail.
If the -E option is specified, then if a call to the
realpath()
function with the specified pathname as its first argument would encounter an error condition other than [ENOENT], the canonicalization shall fail; if the call would encounter an [ENOENT] error, realpath shall expand all symbolic links that would be encountered in an attempt to resolve the specified pathname using the algorithm specified in XBD 4.16 Pathname Resolution, except that any trailing<slash>
characters that are not also leading<slash>
characters shall be ignored. If this expansion succeeds and the path prefix of the expanded pathname resolves to an existing directory, the canonicalized pathname shall be the expanded pathname. In all other cases, the canonicalization shall fail. If the expanded pathname is not empty, does not begin with a<slash>
, and has exactly one pathname component, it shall be treated as if it had a path prefix of "./
".If no options are specified, realpath shall canonicalize the specified pathname in an unspecified manner such that the resulting absolute pathname does not contain any components that refer to files of type symbolic link and does not contain any components that are dot or dot-dot.
Upon successful canonicalization, realpath shall write the canonicalized pathname, followed by a
<newline>
character, to standard output.If canonicalization fails, or the canonicalized pathname is empty, nothing shall be written to standard output, a diagnostic message shall be written to standard error, and realpath shall exit with non-zero status.
[...]
My question is: the -e
option of realpath
is already supported by at least GNU and Solaris, but I can't find any mention of the -E
option in any realpath
that I could check (macOS, FreeBSD, Solaris, GNU). Did the OpenGroup invent it?