Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

ksh inherits readonly exported variables from the parent, breaking scripts #1505

Description

@vlmarek
$ ksh --version
  version         sh (AT&T Research) 93u+m/1.0.0-beta.2 2021-12-17

I know, not the latest version so I'm terribly sorry if I report already fixed issue.

$ cat aaa
#!/usr/bin/ksh
VAR=yes
typeset -p VAR

$ chmod +x aaa

$ ksh -c 'readonly VAR=foo ; export VAR; ./aaa' 
./aaa: line 1: VAR: is read only


# similarly integer variables

$ ksh -c 'typeset -i VAR=123; export VAR; ./aaa'
typeset -x -i VAR=0

I would expect the new process inherit the exported variable, but not the type of variable. The script can protect himself against integer variables by running typeset VAR=yes which is not reasonable (to me) to do for any and all variables used. I don't know if there is a way to un-readonly a variable at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions