[Bash-completion-devel] -o posix, IFS and local

Freddy Vulto fvulto at gmail.com
Sat Feb 6 12:57:51 UTC 2010


On 100206 01:55, Crestez Dan Leonard wrote:
> Some digging reveals that bash-completion tests run with the shell in -o
> posix mode and that the IFS leak is correct behavior. Bash doc states in
> 6.11 (Bash POSIX mode) point 23:
> 
> """ Assignment statements preceding posix special builtins persist in
> the shell environment after the builtin completes. """
> http://www.gnu.org/software/bash/manual/bashref.html#Bash-POSIX-Mode
> 
> And indeed; eval is a builtin. But this does not actually explain why
> marking a variable as local has any effect. As far as I can tell the
> code should *always* leak the IFS change. Whether the fs_* vars are
> local or not should be irrelevant.
> 
> This behavior makes absolutely no sense to me. I even tried to reproduce
> in a standalone script but -o posix behaved as advertised and IFS always
> leaked.
> 
> I'm just going to skip this and simply save/restore the value of IFS.
> But if anyone can make sense of this; please tell me.

I was able to reproduce the problem on bash-4.0.33 and bash-3.2.39 with a very
little script:

    set -o posix
    t() {
        local x
        BAR=a eval true
    }
    BAR=b; t; echo $BAR

outputs "a", but with `#local x' commented outputs "b", whereas it should
always output "a" according to your citation.  I can't make sense of it either.
I think we should report this to bug-bash at gnu.org

Freddy Vulto
http://fvue.nl



More information about the Bash-completion-devel mailing list