From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13335 invoked by alias); 7 May 2015 22:05:45 -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: 20193 Received: (qmail 18863 invoked from network); 7 May 2015 22:05:41 -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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,T_FSL_HELO_BARE_IP_2 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1431035676; bh=U6596yErYwUlAFj+Avwav7yaxvEPe0e2uFGtjIJLOH4=; h=From:To:Cc:In-Reply-To:References:Subject:Date; b=qW6oW1o5SWhNxh9q7uUG5QNqo+CqzyHlXMsT6btaqV8Nc7TSm/GWXb5gx2re65Jt0 cONkK2DvEz8n88Atdzcx53HiFQJe9Ortkb7bF/DocowUdsR60X9lUXEyqEylKAzc/Z g3lk7cv8caixZIcAuhKNfQVLISLJWdyBptkKtjPI= From: ZyX To: Kannan Varadhan , Eric Cook Cc: "zsh-users@zsh.org" In-Reply-To: <5427ED9E-C5F2-472F-B6B7-662962830ED8@gmail.com> References: <67F1153E-5D3C-4D29-BDD0-1BB9C71FF55A@gmail.com> <554A7E95.7000306@gmx.com> <5427ED9E-C5F2-472F-B6B7-662962830ED8@gmail.com> Subject: Re: new user questions and issues MIME-Version: 1.0 Message-Id: <2934101431035675@web27m.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 08 May 2015 00:54:35 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r About local: instead of setting an option it looks like you can use typeset +g _t3 (`typeset +g`, `typeset` and `local` are almost equivalent, but typeset without any flags listed in documentation exhibits the same behaviour as `local`). Specifically in the example you can use local _t3=XXX__${_t2}__ : when there is an assignment `local` will not print previous value. 08.05.2015, 00:47, "Kannan Varadhan" : > 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: >> >> šI can snipe the easier to explain ones. >> šOn 05/06/2015 01:37 PM, Kannan Varadhan wrote: >>> šIssue #1: šProgrammatic Scripting, how to? >>> >>> šI would like to do the following: >>> >>> šfor var in path infopath manpath cdpath ; do >>> šššštypeset -agU $var >>> ššššlocal capsvar >>> ššššcapsvar=$(echo $var | tr 'a-z' 'A-Z') >>> šššš$var=( $(echo ${$capsvar} | sed 's/:/ /g') ) >>> šdone >>> >>> šBut this does not work, because ${$capsvar} šgets me a zsh: bad substitution. >>> šIs there any way to achieve this in zsh? >> šYou can use the parameter expansion flag P. ''${(P)capsvar}'' >> >> š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. >> >> šecho by default interprets c string escapes, you can disable that with >> šthe -E option. >> >> šYou could avoid the command substitution with the parameter expansion >> šflag U ''capsvar=${(U)var}'' to change the case of the value. >> >> š$var=(...) is also an error. ''set -A $var element1 element2 ...'' will >> šallow you to indirectly set arrays >>> šIssue #2. šOverridden local variables get echoed? >>> >>> š~ 5% cat lib/zsh/test2 ššššššššššššššššššššššššššššššššššššššššššššššššš9:55:52 >>> šfunction test2 >>> šššš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. >> >> š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. >> >> š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.