From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19059 invoked by alias); 22 Oct 2016 06:29:07 -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: 22021 Received: (qmail 15760 invoked from network); 22 Oct 2016 06:29:07 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua0-f176.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.217.176):SA:0(0.0/5.0):. Processed in 0.823894 secs); 22 Oct 2016 06:29:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=FeBh3wpn6acSEf/seX7jZDgXdmCsx02eeQvYLPBVeRo=; b=yta1Na64XozXY1U3L8fBXasP1jCLMpAlH3vSzNuwt0be4AjAoKdy5lC88lTHsWIYL2 xR23GFhC+5Cnnp02vM0D3O6dg0652Icq9LyATNH/kc6Tjtc4oD9BLvbo/cwJ/evltEDk mQzf19uBzA6K46/ZWTLdxE9GHqpeliGil5wpoadjphqtKk1hxjKUWm8EVg1UKE6+SM4O yx164qyphNdYx2IiPDnX+ADho/CoTDbhgoqINKRpdjuOisGflvaIsluQQ82Bq8crUcDD uqWJ+bQBg+HEoJnryM4Un3PMH+/5bSiGk7v8ejHuPuIScXIAKBPIsb9K7JodU8YtQcOd ztVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=FeBh3wpn6acSEf/seX7jZDgXdmCsx02eeQvYLPBVeRo=; b=YtuOUoCdN2DfcJ6wz8GbZpwgziQ4xRyPvlWllkg97v4IFERCFdNLiLmM7WQVr4pbFl nULTVmqOGf8GJZJhHP08do8EvER9J+1YOYiCXYS96747j4OdjglnxiKM/lL63l7TjRki 8G3NHANffV7K6EH6Zd9MLlMF477HW5GLHwnZ4NHy8OZk9hcYfbu9ylunGu+3uN6/8mEE x3IlCgFz6OBq8KF4baTYcOAdYmmZ/vEMf7D2IClrm27l04RDiT2dFHwLTbD9Q5vIJgqd lE6XNxz+2y9L+KsJGSaS2wboMhReHQVHWEJJuQkVhM2sQzZNF5tXPNIxcuC0Q3jLCpnw MbNg== X-Gm-Message-State: ABUngvdYZzk2UND4TtUeP6LX2b8xh2fgGkNcbCn0muRRVFKZkIp6uZ6UOOrjbm/qsco6rw== X-Received: by 10.176.68.6 with SMTP id m6mr463973uam.82.1477115855026; Fri, 21 Oct 2016 22:57:35 -0700 (PDT) From: Bart Schaefer Message-Id: <161021225738.ZM10714@torch.brasslantern.com> Date: Fri, 21 Oct 2016 22:57:38 -0700 In-Reply-To: <4961661477083984@web22h.yandex.ru> Comments: In reply to "Nikolay Aleksandrovich Pavlov (ZyX)" "Re: Checking if a variable is exported" (Oct 22, 12:06am) References: <032fd4ec-89c1-9dae-a729-c440048ff3ec@inlv.org> <4961661477083984@web22h.yandex.ru> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-users@zsh.org" Subject: Re: Checking if a variable is exported MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 22, 12:06am, Nikolay Aleksandrovich Pavlov (ZyX) wrote: } } BTW, if I use } } () { echo ${(Pts.-.)1} } PATH } } I get `scalar export special` like expected. But I always get return } status 1 when using } } () { (( !! ${${(Pts.-.)1}[(Ie)export]} )) } PATH This is explained in the doc for (P): ... if the reference is itself nested, the expression with the flag is treated as if it were directly replaced by the parameter name. It is an error if this nested substitution produces an array with more than one word. For example, if `name=assoc' where the parameter assoc is an associative array, --> then `${${(P)name}[elt]}' refers to the element of the associative --> subscripted `elt'. And then later: Note that, unless the `(P)' flag is present, the flags and any subscripts apply directly to the value of the nested substitution; for example, the expansion ${${foo}} behaves exactly the same as --> ${foo}. When the `(P)' flag is present in a nested substitution, --> the other substitution rules are applied to the value _before_ it --> is interpreted as a name, so ${${(P)foo}} may differ from ${(P)foo}. So what you need is to isolate ${(P)1} from all other parameter flags and also separate it from the subscript expression: torch% () { echo ${(ts.-.)${(P)1}} } PATH scalar export special torch% () { echo ${${(ts.-.)${(P)1}}[(I)export]} } PATH 2