Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 May 2010 20:27:19 -0700
From:      Charlie Kester <corky1951@comcast.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: unexpected operator .sh error
Message-ID:  <20100601032719.GR216@comcast.net>
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 Mon 31 May 2010 at 19:58:41 PDT Aiza wrote:
>Chris Hill wrote:
>>On Tue, 1 Jun 2010, Aiza wrote:
>>
>>>Added some code to a .sh script.
>>>When I run the script works but issues this message
>>>[: =: unexpected operator
>>>
>>>No line number telling where to look.
>>>I am not ever sure its talking about.
>>>
>>>IS [: whats wrong or =:
>>
>>I'd guess that what you added includes something like
>>  if [ x=y ]
>>  ...
>>
>>The open-square-bracket, [, is another name for test. IIRC the 
>>equal sign is not valid in that context.
>>
>>Can you post the 'before' and 'after' versions of that part of your 
>>script? It would help us in determining what the problem is.
>>
>>-- 
>>Chris Hill               chris@monochrome.org
>
>
>That hint got me to the correct line
>
>I had    if [$1 = "basejail" ]; then

You need a space after the opening [ or it doesn't parse correctly.

As Chris said, it's another name for test, so think of it as a word,
i.e., something delimited by whitespace.





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