From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22594 invoked from network); 13 Sep 2008 14:53:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Sep 2008 14:53:52 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 61991 invoked from network); 13 Sep 2008 14:53:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Sep 2008 14:53:18 -0000 Received: (qmail 1090 invoked by alias); 13 Sep 2008 14:53:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25657 Received: (qmail 1073 invoked from network); 13 Sep 2008 14:53:06 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 13 Sep 2008 14:53:06 -0000 Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.225]) by bifrost.dotsrc.org (Postfix) with ESMTP id C3381802710B for ; Sat, 13 Sep 2008 16:52:42 +0200 (CEST) Received: by rv-out-0506.google.com with SMTP id g37so1171611rvb.21 for ; Sat, 13 Sep 2008 07:52:35 -0700 (PDT) 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= Received: by 10.114.202.15 with SMTP id z15mr4450825waf.88.1221317555696; Sat, 13 Sep 2008 07:52:35 -0700 (PDT) Received: by 10.114.159.2 with HTTP; Sat, 13 Sep 2008 07:52:35 -0700 (PDT) Message-ID: <6cd6de210809130752p4a5dc634v6144b0475e2cc569@mail.gmail.com> Date: Sat, 13 Sep 2008 10:52:35 -0400 From: "Rocky Bernstein" To: "Zsh Hackers' List" Subject: Should declare -p add a new declaration inside a function? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_30848_15074161.1221317555695" X-Virus-Scanned: ClamAV 0.92.1/8230/Sat Sep 13 02:08:14 2008 on bifrost X-Virus-Status: Clean ------=_Part_30848_15074161.1221317555695 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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) ------=_Part_30848_15074161.1221317555695 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
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)



------=_Part_30848_15074161.1221317555695--