Source-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: src/usr.bin/stat
Module Name: src
Committed By: kre
Date: Sat May 3 21:34:09 UTC 2025
Modified Files:
src/usr.bin/stat: readlink.1 stat.c
Log Message:
Make readlink(1) compliant with the POSIX-2004 (Issue 8).
POSIX 2004 requires that if a given file name to readlink(1)
doesn't refer to a symlink, an error be printed.
That conflicts with historic usage on NetBSD where readlink is
silent in that case (except for the exit status) -- rather than
altering our default behaviour, look for POSIXLY_CORRECT in the
environment, and issue an error only in that case (just means
switching between -q and -v as the default noise option).
While here, generate usage if no file args are given - POSIX
requires at least 1 (it actually specifies exactly 1) and while
we can extend that without issues to allow more than one, allowing
0 args (just because we do that for stat(1) and readlink(1) is
the same code) makes no sense at all for readlink - stdin cannot
possibly be a symbolic link.
Also, in the case of stat(1) if we do have no args, and the
fstat(STDIN) fails for some reason, don't claim that it is
lstat (or stat, depending upon -L) which failed:
stat: (stdin): lstat: Bad file descriptor
makes no sense at all. This can occur with something like
stat <&-
which is kind of obscure, but it is easy to DTRT.
No pullups planned.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/stat/readlink.1
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/stat/stat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Home |
Main Index |
Thread Index |
Old Index