procmail
[Top] [All Lists]

Re: * ! ? $TEST -d "$some_directory" may not work as expected

2004-03-28 00:48:40
On Sat, 27 Mar 2004, 17:37 GMT-06 David W. Tamkin wrote:

1. Are you saying that if

a. [ $TEST = test ] and
b. /bin/test did not exist when procmail was compiled,

then for

  * ? $TEST parameters

procmail spots "test" and invokes a shell,

yes, assuming (b) is the case for the procmail binary in question
(since I did not compile it myself; I cannot confirm, but that seems to
be the case).

but for

  * $ ? "$TEST parameters"

where there are no shell metacharacters on the line, procmail will 
search $PATH for an executable named test?  (I don't have access to a
system without /bin/test, so I cannot try it out for myself.)  Then 
you've uncovered quite a quirk.

No, unfortunately not. The only advantage of using

* $ ?"$TEST parameters"

instead of

*  ? $TEST parameters

is, on a system where (a) and (b) above is true, that, let me say, the
variable expansion is done before passing the entire command to the
extra shell. Please forgive me if that is not technically correct and
when I did not use the correct words in my previous postings about
that. I have now also corrected the subject, by adding " as expected"
to "may not work".

The facts are, that procmail's corresponding verbose log line for case 1 above 
is

procmail: Executing " $TEST -d "$av_REQUIRED_DIR""

while for case 2 it is

procmail: Executing "test -d /home/roal/mail/TRASH/viruses/EXE"

When TEST is set to the proper location of the actual 'test' binary
(which is '/usr/bin/test' on the system in question), no problem is
observable, regardless of which of the above two forms of writing the
condition is used, resulting in "resolving the variable names on the
procmail layer" (this expression may also not be 100% technically
correct) and not invoking an extra shell:

procmail: Executing "/usr/bin/test,-d,/home/roal/mail/TRASH/viruses/EXE"

3. What determines in the first place whether $TEST is a full path or
just the word "test"?

procmail: Assigning "TEST=/usr/bin/test"

vs.

procmail: Assigning "TEST=test"

rob.


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