Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Should declare -p add a new declaration inside a function?
- X-seq: zsh-workers 25657
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "Zsh Hackers' List" <zsh-workers@xxxxxxxxxx>
- Subject: Should declare -p add a new declaration inside a function?
- Date: Sat, 13 Sep 2008 10:52:35 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=kvOhhE7dyyY4wS1mzQGpU0x+TAyZhKRTTmxdTXtqdg0=; b=w50uNNdEf6dEcd7X4jrsW4ATGFjgIAt+Q43mDN+9wVH2EQIutIjgst9m6/dCIHuBMg 0gSl3eMH8mv1U0yjNVN7pM9/Er9Uju6uRQEQ83r5QX6z10ZuGT8t++J8T2yhQOdPUGXM /sQ/ICa0ox6jg/f2HLvPp9Dt/hFEoK44KPMpE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=L7n+HUwokHIWA/5faBM6bS6Itgz8J8tNxlAPWy0jwgrh/U3d5+aR04f8uHFek++mNu DFGhWcn62F5X8BnfysZ3jX5W2/s5yaxDBYoNWtfNsF3ApCNKj5u3bMQDn/FFwUxdODts rIiq3iSLZKMRrl74PHIK+6mT54lEW/QriOEsw=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author