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

Re: nother bash question



On Mon 13 Jun 2016 at 05:17:42 (-0400), Gene Heskett wrote:
> On Monday 13 June 2016 04:19:46 Thomas Schmitt wrote:
> 
> > Hi,
> >
> > Gene Heskett wrote:
> > > if test ${InMail} = "gene"
> > > bin/mailwatcher: line 66: test: =: unary operator expected
> >
> > The syntax problem is most probably about missing "-quotes around
> > the variable ecaluation ${InMail} which would have to be empty to
> > cause the message:
> >
> >   $ test $notdefined = "hello world"
> >   -bash: test: =: unary operator expected
> >   $ test "$notdefined" = "hello world"
> >
> >   $ defined=x
> >   $ test $defined = "hello world"
> >   $
> >
> > Another negative syntax effect would happen if ${InMail} did consist
> > of more than one word:
> 
> The likelyhood of that is .0000000slim to none, my procmail would have to 
> have developed a tummy ache, and I'd have lots bigger problems.

We have been here before, too.

https://lists.debian.org/debian-user/2016/04/msg00675.html

So why do you want to discover some future problem in procmail by
having this script blow up?

> >   $ multiword="x y"
> >   $ test $multiword = "hello world"
> >   -bash: test: too many arguments
> >
> > (On the other hand, "gene" does not need its quotes because the
> >  text is a single constant word. "hello world" needs them, because
> >  of the blank on the middel.)
> Ahh, I see.
> > -------------------------------------------------------------------
> >
> > Is ${InMail} supposed to be empty ?
> > If not, then the script has another problem about properly setting
> > the variable.
> >
> That is set by inotifywait's return of the name of the file that procmail 
> just closed.  It may not be a match with my tests as there a virii file 
> there too.  But clamd isn't catching but maybe 10% of that.
> 
> I should probably clear InName to "", but inotifywait has been coping 
> with that for about a decade :)

Hence the reference to "when it *is* empty, it'll be in five years time".

I can't understand why you prefer to have to check a load of logic
(which you outlined in more detail in
https://lists.debian.org/debian-user/2016/04/msg00676.html
) rather than write a few defensively-written tests.

Cheers,
David.


Reply to: