bug-bash
[Top][All Lists]
Advanced

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

Re: Syntax error when using extended patterns inside functions


From: Chet Ramey
Subject: Re: Syntax error when using extended patterns inside functions
Date: Mon, 24 Jun 2002 12:09:48 -0400

> Bash Version: 2.05a
> Patch Level: 0
> Release Status: release
> 
> Description:
>    While executing a function, a syntax error occurs when some
>    extended pattern matching features appear in a '[[' compound
>    command.
>    The same '[[' compound command outside a function works well.

One of the slightly clunky parts of the `extglob' shell option is that
it changes the shell's parsing behavior (it has to -- [[ becomes part
of the shell grammar).  Without extglob active, the `[[...]]' is not
parsed specially. 

A function definition is parsed in its entirety when read and then
stored for future use.  If `extglob' is not enabled when the function
is parsed, the [[...]] stuff is likely to cause a syntax error.  Since
the function in question turns on extglob itself, and it is not
enabled beforehand, the parser doesn't know it should handle the
extended globbing constructs.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    chet@po.CWRU.Edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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