| Good point. However, if you tell it to create 2 lockfiles, one of which
| it will never be able to create, it will tidy up after itself.
| Something like:
| lockfile -r0 plainfile /dev/null/blah
| Obviously it will never be able to create the file 'blah' in the
| directory '/dev/null/'!
That's clever! And if plainfile existed previously, lockfile gives up right
then and doesn't remove it. Interesting.
| The exitcode will differ depending on whether or not 'plainfile' exists.
| It'll return 69 if plainfile is there, and 73 if it isn't. Of course,
| you then need to do extra work to grab and test the return value:
| DUMMY=`lockfile -r0 plainfile /dev/null/blah`
| * RET ? 69
There's really very little extra work:
:0 # first condition scores -69 if plainfile exists, -73 if it doesn't
* unset ?? -1^1 ! ? lockfile -r0 plainfile /dev/null/blah
or to test for nonexistence,
:0 # first condition scores 69 if plainfile exists, 73 if it doesn't
* unset ?? 1^1 ! ? lockfile -r0 plainfile /dev/null/blah
| which seems like too much pain when head will do the job.
But it's fascinating. Thank you. Also, if you add lockfile's -! option:
lockfile -! -r0 plainfile /dev/null/blah
it returns 0 if plainfile already existed and 73 if it did not and lockfile
choked instead on the permissions problem of creating /dev/null/blah.
Anyhow, I'm sticking with head -0 unless somebody thinks of a way to do it
wholly in procmail internals.
procmail mailing list