Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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).

share|improve this answer
1  
Gilles, you teach me something new everyday here :-) –  Nikhil Mulley Jan 6 '12 at 18:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.