Is it possible to unset or change a readonly variable in Korn Shell? I am using AIX 5.

1 Answer 1


Not that I know of. At least, the obvious ways won't work: you can't unset a readonly variable or remove the readonly attribute with typeset +r. This goes for all the ksh variants that I've seen, and for bash, but there are apparently ksh versions such as on AIX 4.3 that allow typeset +r (which zsh also allows).

Technically, you can do this from outside: connect to the ksh process with a debugger and flip the bit in memory where the ksh process stores the information that the variable is read-only. So a readonly variable is not an absolute security feature.

If you need to set a variable to a different value before launching a command, do it through env:

readonly foo='some value'
env foo='other value' mycommand

Alternatively, make the variable read-only in a restricted scope (in a function).

  • 1
    Gilles, you teach me something new everyday here :-) Jan 6, 2012 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .