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

Re: My script almost works but spams the terminal its launched from if useing dash.



On Sun 17 Apr 2016 at 00:41:03 (-0400), Gene Heskett wrote:
> On Saturday 16 April 2016 22:18:34 David Wright wrote:
> > On Sat 16 Apr 2016 at 19:06:42 (-0400), Gene Heskett wrote:
> > > On Saturday 16 April 2016 14:02:16 Thomas Schmitt wrote:
> > > > Gene Heskett wrote:
> > > > > There are too many places where a conditional would be needed
> > > >
> > > > The classic way is to use only gestures which are supported by the
> > > > Bourne shell and to avoid certain peculiarities of some shells.
> > > > In ./configure scripts of source packages one can see gestures
> > > > like
> > > >
> > > >           if test "x${InMail}" = xgene
> > > >
> > > > which avoids to compare empty variable content.
> > >
> > > In normal everyday operation, the variable ${InMail} will not be
> > > empty.
> >
> > That may or may not be a useful observation. However, sod's law
> > dictates that when it *is* empty, it'll be in five years time when
> > you've forgotten how and why you converted your script, and you
> > desparately need it to work _now_.
> 
> Each new incoming  email is another pass thru the loop. There are 3 
> possible names for the mailfile itself as procmail determines that.

Which nicely illustrates the point of defensive programming.
It's not *your* script that will necessarily make the first mistake,
but you don't want procmail's unexpected input to derail your script
and produce a cascade of errors. Let's face it, shell error messages
are not the easiest to decode: that was the reason for your OP.

And pointing out how your procmail system can't get it wrong is no
defence. If you're using an unsafe test in one place, it's likely
there are other ones in your scripts (assuming this isn't the only
script you have).

Cheers,
David.


Reply to: