1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix spurious export attribute when printing compound variables

Reproducer script:

    typeset -Ttyp1 typ1=(
            function get {
                    .sh.value="'Sample'";
            }
    )
    typ1 var11
    typeset -p .sh.type
    typeset -p .sh.type

Buggy output:

    namespace sh.type
    {
            typeset -r typ1='Sample'
    }
    namespace sh.type
    {
            typeset -x -r typ1='Sample'
    }

An -x (export) attribute is magically pulled out of a hat.

Analysis: The walk_tree() function in nvdisc.c repurposes (!) the
NV_EXPORT attribute as an instruction to turn *off* indenting when
pretty-printing the values of compound variables. The
print_namval() function in typeset.c, implementing 'typeset -p',
turns on NV_EXPORT for compound variables to inhibit indentation.
But it then does not bother to turn it off, which causes this bug.

src/cmd/ksh93/bltins/typeset.c: print_namval():
- When printing compound variables, only turn on NV_EXPORT
  temporarily.

Resolves: https://github.com/ksh93/ksh/issues/456
This commit is contained in:
Martijn Dekker 2022-06-07 04:16:48 +01:00
parent 80f8cc497f
commit 9da0887e54
4 changed files with 56 additions and 3 deletions

5
NEWS
View file

@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
Any uppercase BUG_* names are modernish shell bug IDs.
2022-06-07:
- Fixed a bug in 'typeset' where compound variables could acquire a spurious
-x (export) attribute when printing their values, triggering other bugs.
2022-06-05:
- Fixed a bug where tab completion would spuriously execute a command