Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 May 2010 23:22:01 -0400
From:      Sahil Tandon <sahil@FreeBSD.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: unexpected operator .sh error
Message-ID:  <20100601032201.GA1333@magic.hamla.org>
In-Reply-To: <4C047761.2040403@comclark.com>
References:  <4C046937.2030905@comclark.com> <alpine.BSF.2.00.1005312224010.3508@tripel.monochrome.org> <4C047761.2040403@comclark.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 01 Jun 2010, Aiza wrote:

> Chris Hill wrote:
> >The open-square-bracket, [, is another name for test. IIRC the
> >equal sign is not valid in that context.

Using '=' within test(1) brackets should be fine.

> >Can you post the 'before' and 'after' versions of that part of
> >your script? It would help us in determining what the problem is.
> 
> That hint got me to the correct line
> 
> I had    if [$1 = "basejail" ]; then

As noted by Chris and the sh(1) man page, '[' is a built-in equivalent
of test(1).  The correct syntax for an expression inside those brackets
requires *spacing*, i.e. [ expression ], and not [expression ], as in
your example.

-- 
Sahil Tandon <sahil@FreeBSD.org>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100601032201.GA1333>