touch -c behaves incorrectly (non-POSIX)

POSIX says about 'touch'[*]:

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


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

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

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 (

Leave a Reply

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