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

Re: nother bash question



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:

  $ 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.)

-------------------------------------------------------------------

Is ${InMail} supposed to be empty ?
If not, then the script has another problem about properly setting
the variable.


Have a nice day :)

Thomas


Reply to: