[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error parsing file glob when importing function from environment
From: |
Stephane Chazelas |
Subject: |
Re: error parsing file glob when importing function from environment |
Date: |
Thu, 26 Feb 2015 22:24:02 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2015-02-26 16:35:14 -0500, Chet Ramey:
> On 2/26/15 2:37 PM, adyer@ptc.com wrote:
>
> > Bash Version: 4.2
> > Patch Level: 47
> > Release Status: release
> >
> > Description:
> > A bash function containing the syntax "files=( !(PAT) )" fails to parse
> > in a sub-shell when imported from the environment (to which it was
> > exported
> > by the parent shell).
>
> The extended globbing syntax is accepted by the parser when the `extglob'
> shell option is enabled. If you (or some agent) export a function using
> that syntax, you will need to make sure that the extglob option is enabled
> when it's parsed by the subshell.
[...]
That doesn't seem to work when exporting the option with
BASHOPTS though.
env BASHOPTS=extglob bash -c '
f() { echo !(??*); }
export -f f
echo calling bash
bash -c "shopt | grep extglob"'
gives:
calling bash
bash: f: line 0: syntax error near unexpected token `('
bash: f: line 0: `f () { echo !(??*)'
bash: error importing function definition for `f'
extglob on
Same problem with:
echo shopt -s extglob > ~/.bashenv
BASH_ENV=~/.bashenv bash -c '
f() { echo !(??*); }
export -f f
echo calling bash
bash -c "shopt | grep extglob"'
This is OK:
bash -O extglob -c '
f() { echo !(??*); }
export -f f
echo calling bash
bash -O extglob -c "shopt | grep extglob"'
--
Stephane