[Top][All Lists]

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

Re: unbalanced parenthesis not recognized

From: Greg Wooledge
Subject: Re: unbalanced parenthesis not recognized
Date: Fri, 19 Nov 2021 07:47:21 -0500

On Fri, Nov 19, 2021 at 08:02:19AM +0100, Harald Dunkel wrote:
> On 2021-11-18 17:52:29, Robert Elz wrote:
> >      Date:        Thu, 18 Nov 2021 10:34:40 +0100
> >      From:        Harald Dunkel <harald.dunkel@aixigo.com>
> >      Message-ID:  <fff15881-9ee7-ce68-6d86-daa81a7d6d6b@aixigo.com>
> > 
> >    | at least due to unbalanced parenthesis?
> > 
> > Greg's reply was correct, but he didn't explicitly address that point.
> > In sh, characters like { } [ ] (but not ( and )) are just characters.
> > In some scenarios they're required to be paired for things to work, but
> > you can always simply use one (unquoted) anywhere there's a need.  They
> > don't have to balance in any way.
> > 
> "Some scenarios" is the point here. The parenthesis have to balance as
> soon as it comes to shell parameter expansion, which is (or should have
> been) the case here. Something like
>       : ${SSLDIR:="${JM_WORK}/ssl"
> doesn't work, either.
> You have to admit that this was a mean pitfall.

You're expecting curly braces to have special meaning.  They don't.
Curly braces only have special meaning in three highly specific scenarios:

1) The { appears after a $ character.

2) An unquoted { } pair appears with an unquoted comma between them,
   triggering brace expansion.

3) { appears alone in the command position, indicating the start of a
   braced command group.

In all other scenarios, { and } are simply ordinary characters with no
special meaning.

Number 2 is tricky.  You can get unexpected results if you feed an
ambiguous set of unbalanced curlies to the parser.  I would not recommend
using brace expansion in scripts.  It's really intended only for
interactive use, to save typing in relatively simple commands.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]