[Top][All Lists]

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

Re: "shopt -s extglob" inside of a function does not work

From: Chet Ramey
Subject: Re: "shopt -s extglob" inside of a function does not work
Date: Thu, 02 Feb 2006 23:07:06 -0500
User-agent: Thunderbird 1.5 (Macintosh/20051201)

Michael Wang wrote:

> "
> line 5: syntax error in conditional expression: unexpected token `('
> line 5: syntax error near `@(a'
> line 5: `if [[ "a" == @(a) ]]'
> "
> when run under bash. I believe it should not because "extglob"
> is enabled inside the function. If I run the script inside the
> function line by line, it works. And if "extglob" is enabled
> outside the function, it also works.

Nope.  Will not work, cannot work.  A function definition is parsed
in its entirety before any commands within are executed.  Since the
extglob option changes the behavior of the parser, it must be enabled
before trying to parse the function.

``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                                Live Strong.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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