bug-bash
[Top][All Lists]
Advanced

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

declare in a function makes a variable unable to be found with declare -


From: SN
Subject: declare in a function makes a variable unable to be found with declare -p in some cases
Date: Mon, 16 Feb 2015 21:38:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hello all,

I have found a problem with the declare builtin.

Patch Level: 33
Release Status: release

Description:
        Apparently, there is a problem with how bash interprets some
variable assignments.
        It only happens in a function (probably related to `declare'
making variables local).

Repeat-By:
        # OK
        $ x() { declare -a var=(); declare -p var; }; x
        declare -a var='()'
        # not OK
        $ y() { declare -a var='()'; declare -p var; }; y
        bash: declare: var: not found

        Note that the format used in y is what `declare -p' displays.

        By the way, empty arrays seem to be reported as "not set".
        a=(); test -v a || echo "not set"
        This might be related (or not), but consider that the return
status of `test -v'
        is different on a bash version unaffected by the bug that I have
tried (4.2.37).



reply via email to

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