Subject: Re: bug#9742: touch option for existence?

From: Morty <[email-masked]>
Date: Thu, 13 Oct 2011 11:43:52 -0400

On Thu, Oct 13, 2011 at 03:37:42PM +0200, Jim Meyering wrote:

> Thanks for the suggestion.
> 
> However, when there's such an easy and portable way to do what you want,
> 
>   touch_if_absent() { test -e "$1" || touch "$1"; }
> 
> it is counterproductive (and contrary to the "Unix way") to encumber
> a tool like "touch" with an option to provide that functionality.
> Besides, then you'd have to wait until a release including your
> option makes it into whatever distribution you use (or build from source).
> With the above, you have something that is portable and works now.

Couldn't the same be said of touch's -c option?  An equivalent
function would be almost identical to what you had above:

  touch_if_present() { test -e "$1" && touch "$1"; }

And yet, we have touch -c.

I know touch -e isn't really necessary, but it makes for nice
syntactic sugar.  This is analagous to GNU touch's -c, GNU tar's -z,
GNU grep's -q, or GNU sed's -i.  Just because you can easily script an
equivalent doesn't mean you should have to.  I also know that even if
-e gets put in today, it will be years before it's on enough systems
that we will actually be able to rely on it.  But I've been around
long enough to see new versions of GNU tools gain really useful
options and then become ubiquitous.  "You won't be able to rely on it
for N years" is not a good reason to refrain from doing something
useful.  N years will pass sooner than you realize, and our future
selves will be grateful to our present selves for planning ahead.

- Morty