On 2007-08-19 13:10:15 -0600, Bob Proulx wrote:
> Vincent Lefevre wrote:
> > The 'touch' documentation (info manual, man page and 'touch --help'
> > output) needs to be clarified.
> > 
> > 1. First, 'touch' follows symbolic links, and the documentation should
> > say that, because this is far from being clear (e.g. 'rm' and 'ls'
> > don't follow symbolic links). I suppose that this is the correct
> > behavior, though POSIX isn't clear either, as BSD 'touch' does the
> > same thing.
> 
> I am sorry that you are frustrated by the way symbolic links operate
> within BSD derived systems.

I'm not frustrated by the way it works. I'm just complaining on the
documentation.

> Symlinks create a fundamental operating
> interface between all programs and the filesystem.  They permeate
> everything that operates on files in a fundamental way.  Because they
> are a very low level interface I don't believe it is possible nor
> appropriate to note how symlinks affect everything everywhere.  The
> best that can be done is to learn how they affect the filesystem
> interface and apply that model to all applications that operate on the
> filesystem.
> 
> The touch command follows symlinks because generally everything
> follows symlinks.  The commands that do not follow symlinks are the
> exceptions to that rule.

I'd say this is the opposite for commands that operate on meta-data
(such as 'touch').

> The rm command is not an exception here because rm operates on
> symbolic links normally.

It is an exception as it doesn't follow the symbolic links.

> The ls command is an exception and where it handles symlinks
> specially is documented.

The stat command (from the coreutils) is also an exception. Ditto for
chown and chgrp. I think that most commands that operate on meta-data
are exceptions!

Note: chmod is a bit special because symlinks don't have file
permissions. Also touch and chmod are different from other file
operations that follow the symlinks in the sense that they don't
return an error if the file doesn't exist:

vin:~> ln -s file link
vin:~> touch -c link
vin:~> chmod 644 link
vin:~> cat link
cat: link: No such file or directory

Isn't that confusing?

> Because 'touch' does not do anything special with regards to symbolic
> links I do not think it needs any exceptions listed for them.  That
> is, if touch mentioned symlinks then every command should mention
> symlinks and that would be too much.

Only commands that operate on meta-data (i.e. not the file contents[*])
are concerned. I don't think that would be too much.

[*] It is implicit that symlinks are followed to get/create/modify
file contents. But meta-data are part of the inode and a symlink has
its own inode.

[...]
> Actually FILE in the above refers to the use of FILE as a command line
> argument to the touch command as noted in the synopsis.  It could say
> the following not using FILE and also be correct:
> 
>        touch [OPTION]... FOO...
> 
>     Any FOO that does not exist is created empty.
> 
>     A FOO of `-' causes `touch' to change the times of the file
>   associated with standard output.

But again, the term "FOO" would be used with two different meanings.

> I could suggest the following:
> 
>        touch [OPTION]... FILE...
> 
>      Any FILE argument that does not exist is created empty.
> 
>      A FILE argument string of `-' is handled specially and causes
>   `touch' to change the times of the file associated with standard output.

OK.

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

Reply via email to