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

Re: nother bash question



Hi,

i wrote:
> > Is ${InMail} supposed to be empty ?

Gene Heskett wrote:
> That is set by inotifywait's return of the name of the file that procmail 
> just closed. 

Hmm. I don't have inotifywait installed.
According to http://linux.die.net/man/1/inotifywait it should put out
lines like
  CLOSE_WRITE:CLOSE goodfile

I guess you pick the second word or the line end of such a line.
It would be interesting to see how you do this.


> I should probably clear InName to "", but inotifywait has been coping 
> with that for about a decade :)

All is well as long as ${InMail} is perceived by the shell parser as
a single shell word. (I.e. a text snippet which the shell parser recognizes
as a unit.)

So i assume that the problem is in the text which your script picks from
the inotifywait reply.
Add to the script some commands which print the line and the text it
picks. Then you get hints what might go wrong and some an to play with
in the shell dialog line.

---------------------------------------------------------------------
Detour into theory:

> > > bin/mailwatcher: line 66: test: =: unary operator expected
tomas@tuxteam.de wrote:
> One could argue "unary operator expected" is a strange way to
> restate this.

It's the way how the gild of land surveyors and bean counters expresses
itself:
Unary operators are for example the logical negation ("not") or the
arithmetic sign ("-").
Binary operators are logical conjunction ("and") or arithmetic
subtraction ("-" again (nobody promised math to be straightforward)).

Since there is only one non-operator given ("gene"), the parser is
unwilling to accept any binary operator. The message is then just an
indication that the programmer was either to concentrated on the
job or that the parser of test does not know enough about its boss
program.
A user-aware programmer of a boss-program-aware parser could well
report: "Operator '=' expects two operands. Only one is given."

Beware: '=' without any operand is considered to be syntactically
        correct and evaluates as "true":

  $ test =
  $ echo $?
  0

because of:
  https://www.gnu.org/software/coreutils/manual/html_node/test-invocation.html#test-invocation
  "If expression is omitted, test returns false. If expression is a single
   argument, test returns false if the argument is null and true otherwise."

I guess the founders of Unix introduced this rule when a byte of storage
was worth more than a dollar.


Have a nice day :)

Thomas


Reply to: