procmail
[Top] [All Lists]

Re: testing for existence of a file without a fork

2002-05-02 12:11:51
On Thu, 2 May 2002, David W. Tamkin wrote:

Is there a way to test for a plain file's existence with procmail
internals?

Failing that, on a system where /bin/test is a shell script, what would you
folks recommend as a small, cheap-to-run fork that (1) can take a filename as
a positional parameter [so that there's no need to fork a shell to handle
"<"], (2) will exit with an error if the file doesn't exist. and (3) will not
read the whole blasted file if it does exist and is long.  The best I can
think of is head -0.

        head is very good idea.  Maybe echo(1) is faster.  Try this:

echo [F]ileName

        If the file exists the answer will be:

Filename

        Else the answer will be:

[F]ilename

        Unfortunately, the status exit will be true in anycase, on the
        other hand you can work with the builtin MATCH.

        What about ls -d ?  I know is biger than head but maybe more
        efficient? 

Bye,
 Udi    

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail