GNU bug report logs -
#9742
touch option for existence?
Previous Next
Reported by: Morty <morty+coreutils <at> frakir.org>
Date: Thu, 13 Oct 2011 01:52:01 UTC
Severity: normal
Tags: notabug
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
Full log
Message #25 received at 9742-close <at> debbugs.gnu.org (full text, mbox):
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
This bug report was last modified 13 years and 228 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.