touch -c behaves incorrectly (non-POSIX)


http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439033

POSIX says about 'touch'[*]:

-c
    Do not create a specified file if it does not exist. Do not write
    any diagnostic messages concerning this condition.

[*] http://www.opengroup.org/onlinepubs/009695399/utilities/touch.html

But under some conditions, 'touch' writes a diagnostic message when
the file doesn't exist. For instance:

vin:~> mkdir dir
vin:~> chmod 000 dir
vin:~> /usr/bin/touch -c dir/file
/usr/bin/touch: setting times of `dir/file': Permission denied
zsh: exit 1     /usr/bin/touch -c dir/file
vin:~[1]>

Note that the BSD 'touch' does not have this problem, as shown by the
test below (under Mac OS X):

prunille:~> mkdir dir
prunille:~> chmod 000 dir
prunille:~> /usr/bin/touch -c dir/file
prunille:~>

Also the touch(1) man page doesn't say that no diagnostic messages
are written when the file doesn't exist. Users are not required to
look at the POSIX standard to get the full documentation.

Ditto for the manual (coreutils.info).
 

Leave a Reply

Your email address will not be published. Required fields are marked *