zsh-workers
 help / color / mirror / code / Atom feed
* leftover debugging statements?
@ 1997-11-01 22:01 ramos
  1997-11-02 11:24 ` C. v. Stuckrad
  1997-11-02 16:48 ` stringfellow.n.d
  0 siblings, 2 replies; 3+ messages in thread
From: ramos @ 1997-11-01 22:01 UTC (permalink / raw)
  To: zsh-workers


hello,

Did somebody leave some leftover debugging statements in
zsh 3.0.5?

Some assignments to a local (typeset) variable cause
some garbage to be printed out.

Example script & output (sorry I don't have time to
isolate this any further... I hope this is enough to
jog someone's memory):

PS1='zsh> '
 
zsh> which bug
bug () {
        typeset fred
        fred=NULL 
        typeset sourcefile
        echo 'Start loop...'
        for sourcefile in $*
        do
                typeset bar
                if [[ $fred = NULL ]]
                then
                        typeset foo
                        foo=(`echo output from some process`) 
                        bar=$foo[0] 
                else
                        bar=$fred 
                fi
        done
        echo 'End loop...'
        return 0
}
 
zsh> bug X Y Z
Start loop...
bar=output
foo=(output from some process)
bar=output
foo=(output from some process)
End loop...
 
zsh> setopt
allexport
autocd
autolist
autopushd
cdablevars
extendedglob
interactive
nolistbeep
login
menucomplete
monitor
pushdignoredups
pushdsilent
rmstarsilent
shinstdin
zle
 
zsh> echo $ZSH_VERSION
3.0.5
 
zsh> uname -a
SunOS ihnns581 5.5.1 Generic_103640-12 sun4u sparc SUNW,Ultra-1
 
##

Obviously, the function was not supposed to print anything out
except "Start loop..." and "End loop...".

Thanks,

--
Alex Ramos


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: leftover debugging statements?
  1997-11-01 22:01 leftover debugging statements? ramos
@ 1997-11-02 11:24 ` C. v. Stuckrad
  1997-11-02 16:48 ` stringfellow.n.d
  1 sibling, 0 replies; 3+ messages in thread
From: C. v. Stuckrad @ 1997-11-02 11:24 UTC (permalink / raw)
  To: ramos; +Cc: zsh-workers

On Sat, 1 Nov 1997 ramos@ih4ess.ih.lucent.com wrote:

> Did somebody leave some leftover debugging statements in
> zsh 3.0.5?
> 
> Some assignments to a local (typeset) variable cause
> some garbage to be printed out.
...
> zsh> uname -a
> SunOS ihnns581 5.5.1 Generic_103640-12 sun4u sparc SUNW,Ultra-1

HERE I can _not_ reproduce it !
ON: SunOS petzval 5.4 Generic_101945-27 sun4m sparc
(Note the differences, older sparc, older OS)

Stucki

Christoph von Stuckrad       * *  | talk to  | <stucki@math.fu-berlin.de> \
Freie Universitaet Berlin    |/_* | nickname | ...!unido!fub!leibniz!stucki|
Fachbereich Mathematik, EDV  |\ * | 'stucki' | Tel:+49 30 838-7545{9|8}    |
Arnimallee 2-6/14195 Berlin  * *  |  on IRC  | Fax:+49 30 838-5913        /


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: leftover debugging statements?
  1997-11-01 22:01 leftover debugging statements? ramos
  1997-11-02 11:24 ` C. v. Stuckrad
@ 1997-11-02 16:48 ` stringfellow.n.d
  1 sibling, 0 replies; 3+ messages in thread
From: stringfellow.n.d @ 1997-11-02 16:48 UTC (permalink / raw)
  To: ramos; +Cc: zsh-workers

ramos@ih4ess.ih.lucent.com wrote:
> 
> hello,
> 
> Did somebody leave some leftover debugging statements in
> zsh 3.0.5?
> 
> Some assignments to a local (typeset) variable cause
> some garbage to be printed out.
> 
> Example script & output (sorry I don't have time to
> isolate this any further... I hope this is enough to
> jog someone's memory):
> 
> PS1='zsh> '
> 
> zsh> which bug
> bug () {
>         typeset fred
>         fred=NULL
>         typeset sourcefile
>         echo 'Start loop...'
>         for sourcefile in $*
>         do
>                 typeset bar
>                 if [[ $fred = NULL ]]
>                 then
>                         typeset foo
>                         foo=(`echo output from some process`)
>                         bar=$foo[0]
>                 else
>                         bar=$fred
>                 fi
>         done
>         echo 'End loop...'
>         return 0
> }
...

Using zsh 3.1.2b I get the following:

zsh> bug X Y Z
Start loop...
bar=output
bar=output
End loop...

where the system is:

zsh> uname -a
SunOS voltera 5.5.1 Generic sun4u sparc SUNW,Ultra-1

The 'bar=output' lines occur when the 'typeset bar' line is
executed, because the previously declared bar is still in scope.
Therefore 'typeset bar' has the same effect as typing 'typeset PATH'
at the prompt, i.e. it returns the current value of the variable
rather than declaring a fresh variable.

The scoping rules for typeset in the Z Shell Guide only mention
variables 
being local to a function (unless I've missed something), so that I
would
expect to get the same output as below

> zsh> bug X Y Z
> Start loop...
> bar=output
> foo=(output from some process)
> bar=output
> foo=(output from some process)
> End loop...
> 

Either moving the typeset statements out of the loop or inserting
explicit
unset statements removes the extraneous output.

N.B.
On my system, using the original bug program leads to the variable foo
being persistant. It may be overwritten with 'foo=...' but any attempt
to unset foo (even after it has been overwritten) resets foo to the
value 'output from some process'.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-11-02 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-01 22:01 leftover debugging statements? ramos
1997-11-02 11:24 ` C. v. Stuckrad
1997-11-02 16:48 ` stringfellow.n.d

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).