From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18799 invoked by alias); 7 May 2015 21:46:13 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20192 Received: (qmail 19819 invoked from network); 7 May 2015 21:46:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=dVGouDE3VfHh/2TZlU/WM0DzGarqTAU/y/v511WHQVQ=; b=qVEi+/uRWAcC6KhHJmeykrvycThHRGPbuzx9MBoSC+mcD1RZOHMW/ksYI7hUK3nw51 qi89JCS4IGCWoGUel/v3OTf0m9uXcj3vN4QYLn6yusUaIOlbsK6ao64hHLIjgAU+J+c4 h6DqCDzGodEVsX2N1aCYQKiDvDDE3R28+0hXRR1oOQy+VLc6xiAZPLqkWzJKkGv4ticI 58pYoPHFUgiWHL38C1jlFRaY6TFYLGvjtq5lN6rK4gFaoVW1+ri8TWJ/ma5bRnLj5Uv+ 4nEXwW/SGAb46R8Ow2080bhtcpTiJPwpXDG1D+QQprDo2uVcDwPppcZSciccnN2uwKq0 egGw== X-Received: by 10.68.69.46 with SMTP id b14mr1144561pbu.110.1431035166174; Thu, 07 May 2015 14:46:06 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: new user questions and issues From: Kannan Varadhan In-Reply-To: <554A7E95.7000306@gmx.com> Date: Thu, 7 May 2015 14:46:11 -0700 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: <5427ED9E-C5F2-472F-B6B7-662962830ED8@gmail.com> References: <67F1153E-5D3C-4D29-BDD0-1BB9C71FF55A@gmail.com> <554A7E95.7000306@gmx.com> To: Eric Cook X-Mailer: Apple Mail (2.2098) Thank you Eric. I had worked out other ways of achieving #1, just wanted to learn if = there was a good way to do it. The others, I get. Thanks, Kannan > On May 6, 2015, at 1:50 PM, Eric Cook wrote: >=20 > I can snipe the easier to explain ones. > On 05/06/2015 01:37 PM, Kannan Varadhan wrote: >=20 >> Issue #1: Programmatic Scripting, how to? >>=20 >> I would like to do the following: >>=20 >> for var in path infopath manpath cdpath ; do >> typeset -agU $var >> local capsvar >> capsvar=3D$(echo $var | tr 'a-z' 'A-Z') >> $var=3D( $(echo ${$capsvar} | sed 's/:/ /g') ) >> done >>=20 >> But this does not work, because ${$capsvar} gets me a zsh: bad = substitution. >> Is there any way to achieve this in zsh? >>=20 > You can use the parameter expansion flag P. ''${(P)capsvar}'' >=20 > With the exception of infopath, The arrays you are trying to define = are > already created and tied to the uppercase scalar parameters. > Any change made to one is reflected in the other. >=20 > echo by default interprets c string escapes, you can disable that with > the -E option. >=20 > You could avoid the command substitution with the parameter expansion > flag U ''capsvar=3D${(U)var}'' to change the case of the value. >=20 > $var=3D(...) is also an error. ''set -A $var element1 element2 ...'' = will > allow you to indirectly set arrays >> Issue #2. Overridden local variables get echoed? >>=20 >> ~ 5% cat lib/zsh/test2 = 9:55:52 >> function test2=20 >> print why is the previous value echoed when a local variable is = 'overridden?' > It actually happens when you use typeset, local, etc. on a parameter > that is already defined. You can use the option TYPESET_SILENT option = to > silence it. >=20 > from the typeset section of zshbuiltins(1): > If the shell option TYPESET_SILENT is not set, for each = remaining > name that refers to a parameter that is set, the name and value of the > parameter are printed in the form of an assignment. Nothing is = printed > for newly-created parameters, or when any attribute flags listed below > are given along with the name. Using `+' instead of minus to = introduce > an attribute turns it off. >=20 >=20 > Pretty sure #3 and #4 is due to how typeset creates a local parameters > when used in a function. So typeset -U PATH create a new parameter > without a value, with the -U attribute.