From:   Martin D Kealey
Subject: bug#79907: Minor minor bug: apropos does not suggest touch
Date:   Mon, 1 Dec 2025 17:02:57 +1000

>I haven't used 'touch' to create a file in more than 30 years, and it
>really surprises me to find anyone still suggesting it as the 'normal'
>way to create files.

>*Any* program that opens an output file is valid for this purpose, as
>long as it can be convinced not to write anything, or only to write
>harmless stuff (which is context dependent).

>Picking on 'touch' as somehow special in this respect is just weird
>(and) very, very old school.

When you get right down to it, a lot (not all or even most, but a lot)
of "coreutils" is "old school" stuff.  For example, test/[ - nobody
uses the coreutils versions of these anymore, because users of modern
shells all have it builtin.  Ditto for a bunch of other things, e.g.,
"printf".

But that doesn't mean that the coreutils maintainers shouldn't put
effort into keeping things clean and up-to-date.

And, yes, for those of us who remember the old days, "touch" *is* the
classic/normal method of creating an empty file.  Note that "touch"
has the advantage of *not* needing your "noclobber" thing, since it is
noclobber by default.  Incidentally, and this is a bit off-topic, but
I've often wished that "touch" had an option like -c, but the opposite
- that is, *always* create (and generate an error if the file already
exists) (*).

(*) I suppose someone will post that using "noclobber" would handle
this, but as I've mentioned elsewhere, I don't like setting global
options like that if I can avoid it...

>In particular, the null command, with a redirection, is both shorter and
>less ambiguous than 'touch'.

Yes, modern users of modern shells usually do it that way (Just do: > file
alone as a line in your script), but note that the "touch" method
became popular when "csh" (now known as "tcsh") was more commonly used
and the "> file" (alone) trick doesn't work in "csh".

=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.

When responding to my posts, please try to refrain from giving bureaucratic 
answers.
If you have nothing useful to say, then just click Next and go on.



Reply via email to