typeset does not make variable local in function

2007-06-06 Thread Clay Harris
Problem:

typeset, when used in a function should always mark the variable as local.
When bash is in ksh mode, it fails to do this.
Previous versions did not have this problem, e.g.
GNU bash, version 3.00.15(1)-release (i386-redhat-linux-gnu)

Recent versions of ksh seem to be exhibiting the same bug.


System:

Linux XXX 2.6.20-1.2948.fc6 #1 SMP Fri Apr 27 19:48:40 EDT 2007 i686 i686 i386 
GNU/Linux
GNU bash, version 3.1.17(1)-release-(i686-redhat-linux-gnu)
Login shell = /bin/bash

Reproduction:


x1:

#!/bin/bash

F1 () {
typeset T1

T1="Wrong!"
}

echo "Before=$T1"
F1
echo "After=$T1"



x2:

#!/bin/ksh

F1 () {
typeset T1

T1="Wrong!"
}

echo "Before=$T1"
F1
echo "After=$T1"


/bin/bash
./x1
Before=
After=
exit

/bin/bash
./x2
Before=
After=Wrong!
exit

/bin/bash -c ". ./x1"
Before=
After=

/bin/bash -c ". ./x2"
Before=
After=

/bin/ksh -c ". ./x1"
Before=
After=Wrong!

/bin/ksh -c ". ./x2"
Before=
After=Wrong!


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: typeset does not make variable local in function

2007-06-06 Thread Clay Harris
I traced the problem down to the ksh that comes packaged
with fedora core.  bash is Fine.  ksh is broken.

On Wed, 6 Jun 2007 23:01 -0400, Chet Ramey quoth thus:

> Clay Harris wrote:
> > Problem:
> >
> > typeset, when used in a function should always mark the variable as local.
> > When bash is in ksh mode, it fails to do this.
>
> I can't reproduce this with bash-3.0, bash-3.1, or bash-3.2 (all patched)
> on MacOS X and FC6.  Bash does not have a `ksh mode'.
>
> Chet


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash