procmail
[Top] [All Lists]

Re: testing for existence of a file without a fork

2002-05-02 12:19:28
Unfortunately, however, that does the job only if the file exists.  If
the file *doesn't* exist, lockfile creates it, and then I need an
additional fork for rm to remove it.

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/'!

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=$?

  :0
  * RET ? 69
  ....

which seems like too much pain when head will do the job.

M
-- 
Martin McCarthy                 /</    http://procmail.non-prophet.org
    `Procmail Companion'        \>\
     Addison Wesley             /</                  PGP key available
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail