bug-bash
[Top][All Lists]
Advanced

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

readonly attribute sticky in function local definition


From: Jim Thomas
Subject: readonly attribute sticky in function local definition
Date: Thu, 21 Feb 2002 11:48:21 -1000 (HST)

Configuration Information [Automatically generated, do not change]:
Machine: hppa1.1
OS: hpux10.20
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='hppa1.1' 
-DCONF_OSTYPE='hpux10.20' -DCONF_MACHTYPE='hppa1.1-hp-hpux10.20' 
-DCONF_VENDOR='hp' -DSHELL -DHAVE_CONFIG_H -DHPUX   -I.  -I. -I./include 
-I./lib -g -O2
uname output: HP-UX atlas B.10.20 A 9000/712 2007201070 two-user license
Machine Type: hppa1.1-hp-hpux10.20

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:
        If a variable is declared readonly globally and an attempt is
made to define a writable local variable of the same name in a
function, the readonly attribute is inherited by the local definition.
[Note in example below, "sh" is HP's "POSIX" shell.]

Repeat-By:

#!/apps/gnu/bin/bash
typeset -i var
A(){
    typeset -i var=2
    echo var $var in func
}
var=1
echo var $var before call
A
echo var $var after call
typeset -ir rovar=1
B(){
    typeset -i rovar=2
    echo rovar $rovar in func
}
echo rovar $rovar before call
B
echo rovar $rovar after call

atlas ~/src/ksh > sh lv.sh
var 1 before call
var 2 in func
var 1 after call
rovar 1 before call
rovar 2 in func
rovar 1 after call
atlas ~/src/ksh > bash lv.sh
var 1 before call
var 2 in func
var 1 after call
rovar 1 before call
lv.sh: typeset: rovar: readonly variable
rovar 1 in func
rovar 1 after call
atlas ~/src/ksh > 



reply via email to

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