[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shopt can't set extglob in a sub-shell?
From: |
Chet Ramey |
Subject: |
Re: shopt can't set extglob in a sub-shell? |
Date: |
Sun, 26 Feb 2012 17:59:13 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
On 2/26/12 6:06 AM, Dan Douglas wrote:
> I just tested a bunch of permutations. I was a bit surprised to see this one
> fail:
You shouldn't have been. The entire function definition, including the
additional embedded function definition, is parsed before any of it is
executed.
>
> f()
> if [[ $FUNCNAME != ${FUNCNAME[1]} ]]; then
> trap 'shopt -u extglob' RETURN
> shopt -s extglob
> f
> else
> f()(
> shopt -s extglob
> echo !(x)
> )
> f
> fi
>
> f
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/