[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9742: touch option for existence?

From: Morty
Subject: bug#9742: touch option for existence?
Date: Thu, 13 Oct 2011 09:21:05 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Thu, Oct 13, 2011 at 10:05:05AM +0100, Pádraig Brady wrote:

> Note the above is easier to express in shell like:
>   [ -e "$file" ] || touch "$file"

Thanks, I'm familiar with it.  :)

> But that is racy.  If you were using touch for locking purposes

I'm using touch to make sure the file exists before an operation that
will yield an error if it doesn't exist.  For example:

touch $resolv
ci -l -t-$resolv -m"check-in existing" $resolv
grep -q domain $resolv || echo domain $domain >> $resolv
ci -l -m"add domain $domain" $resolv

The intent of code like the above is to make sure a certain file is in
revision control and contains a certain setting.  If the file already
is in revision control and has the setting, the code should do
nothing.  But touch changes the mtime.  The problem could be fixed by
slinging around ifs, but that's inelegant.

- Morty

reply via email to

[Prev in Thread] Current Thread [Next in Thread]