From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21945 invoked by alias); 19 Jan 2018 18:47:51 -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: List-Unsubscribe: X-Seq: 23099 Received: (qmail 22918 invoked by uid 1010); 19 Jan 2018 18:47:51 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.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(66.111.4.25):SA:0(-2.6/5.0):. Processed in 2.696792 secs); 19 Jan 2018 18:47:51 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=X3M+qr ohMaMT5TlfGKBSlNY1PBe1jiQLvL4JFUaQlE8=; b=GDA4G/1rPmur0F6nHXtqsP kKSfA7YRVGbrn8Ff81yowNTZjV0nbiPVSIygW3a7F8YCY/kUDu0uZS951XyQYD1I kNxnsI22XzmVUw3HtxZsE2r4Onisqo6NfOPGVacwxZ2cT+iZkKHhmcZKhD4Z0Yn0 4UCKHvZjeowEo/i61gMTUgvzd9j98UY70Lw1ZLHzfpKO1na4rmj3pQMgEWb6rqND jXiZAnyQzqcUgAEEnlAuxMLzkqU3z0Lnqy5rtMZd4LQlgshyshb/L2OGtUSa7kGH tEeUeLXSiULDCmSUVRke365byXi8EzmJatARrB6E45DND6Ye5o2SipnpZrv5oaOw == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=X3M+qr ohMaMT5TlfGKBSlNY1PBe1jiQLvL4JFUaQlE8=; b=MezkZuTlV6+kQQ9NPNVxYg mxULCWoY2ZV1SHGKQMNHUfXHBWrC2BdRWnds/ewOwFkSwNSlBvQwqe5m0Cwv7JK5 RZKx4W8PZL+PbLw5KZXYChh+X5yS4hgDVtUS/UoF2X0A8STjlgAaB8IkR5QR6xUb gXq1X4vfJul2KkBC73ZGaCr2lCNkKN1NvkXL2+xzy5swh7Fnibz7dG8FPQFutp2A GeHuDITKBVnFJND2cGbXZvG+WkYziWwB3IKBlsQFCCdW1ypJultnJFeMMDkna0r/ 1Z5ufz0UiCW9DRECxORa0sMWKw4vi/fUN6vGHUtXzr2mo+wTjkteNszetCpATQ2g == X-ME-Sender: Message-Id: <1516387663.3550697.1241394160.58ECD3D2@webmail.messagingengine.com> From: Daniel Shahaf To: zsh-users@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-75de3051 Subject: Re: Evaluating parameters in general-purpose widgets Date: Fri, 19 Jan 2018 18:47:43 +0000 In-Reply-To: References: <20180119002154.ssgbaowmrjvehme5@tarpaulin.shahaf.local2> Bart Schaefer wrote on Thu, 18 Jan 2018 22:25 -0800: > On Thu, Jan 18, 2018 at 4:21 PM, Daniel Shahaf wrote: > > > > Is it safe for zsh-syntax-highlighting to evaluate parameter expansions > > in the input? > > Depending on how costly you're willing to make this, you could always > use "${$(print -nr -- "$foobar"X)%X}" to assure the parameter is > evaluated where it can't have any effects on the current shell. That's a handy idiom :-). In this case, however, I can think of two issues with it: it wouldn't be performant on platforms where fork() is expensive, and it would mess with modules-provided parameters whose getfn uses out-of-process state. Therefore, I'm currently inclined to . if $parameters[foobar] == *special* ; then # leave it alone else # expand it using ${(P)${:-foobar}} fi . to sidestep module-provided parameters entirely. Thanks, Daniel P.S. For anyone else reading this: using ${(P)} like that is only correct when SH_WORD_SPLIT hasn't been set.