zsh-workers
 help / color / mirror / code / Atom feed
* Should declare -p add a new declaration inside a function?
@ 2008-09-13 14:52 Rocky Bernstein
  2008-09-13 19:55 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Rocky Bernstein @ 2008-09-13 14:52 UTC (permalink / raw)
  To: Zsh Hackers' List

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

It appears that using "declare" or "typeset" with the -p (print) flag will
add a new declaration inside a function. Is this really desirable? It seems
to reduce the usefulness of -p.

Here's an example:

declare -a xx
xx=(an array)
bug() {
    echo xx is \"${xx[@]}\" before \"declare -p xx\"
    echo 'declare -p xx:'
    declare -p xx
    echo xx is now \"${xx[@]}\" in bug
    echo '===='
}
bug
echo 'declare -p xx outside bug:'
declare -p xx


Running this produces:

xx is "an array" before "declare -p xx"
declare -p xx:
typeset xx=''
xx is now "" in bug
====
declare -p xx outside bug:
typeset -a xx
xx=(an array)

[-- Attachment #2: Type: text/html, Size: 933 bytes --]

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

end of thread, other threads:[~2008-09-15 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-13 14:52 Should declare -p add a new declaration inside a function? Rocky Bernstein
2008-09-13 19:55 ` Peter Stephenson
2008-09-14  0:48   ` Rocky Bernstein
2008-09-15  8:53     ` Peter Stephenson
2008-09-15 15:58       ` Rocky Bernstein

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