From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43705-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id e23064b7 for ; Wed, 17 Oct 2018 20:37:39 +0000 (UTC) Received: (qmail 18998 invoked by alias); 17 Oct 2018 20:37:26 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43705 Received: (qmail 16018 invoked by uid 1010); 17 Oct 2018 20:37:26 -0000 X-Qmail-Scanner-Diagnostics: from mail-it1-f194.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.166.194):SA:0(-1.9/5.0):. Processed in 2.144015 secs); 17 Oct 2018 20:37:26 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=mh0Np6as+SbJYf/H+uKhcXKiM3rzRhcOxjjKytHnIqY=; b=Oj3StfSKoVhaFLgK8mTcu49MdlEXaKoT8ykHJMmXubslS4775L0ibiwfnhOJkkk21S z679MDpiloORbP5k1/OJON5lRcJVmTLCBKLFALPrtsOjkB3QHmHljhco2U7rrQElJjil IwDrNXy5JthVhMQOXLZuV3OLNS7ZTz2QjN5NevRp5vRiN77h61YclLxaUpF5EhpYuNk3 Wl05WvasT/AYthMpuREwfO211B12XXnKCVx3FKlkCZMn4Vyob2Lj6G7uNgJjHldBG15G pIk1ztDTLIcfaf5OBwnI9U0lTdBTkPHIOdwRtilYP1jeJ+OL2UNL/4/m/dYHeMLTrF77 WGAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=mh0Np6as+SbJYf/H+uKhcXKiM3rzRhcOxjjKytHnIqY=; b=nQs3sRT7faZEZIDTLHlIWFHyw9pFYFXOsixqviefVzpETNjbPJyIxYr6bfZ9Z4xZxs 1/HPOUInif8Ed4pq9yb3s50QZNN0gLe1sXwJM8YOXKn/xriiDVeNa0yxtUDa3Jrt2Mq3 1SaxQfDm+JgYHwxcqytYEE6zB/n4+Z4ttiks47aj+BHEWH9HdhL6gQVMfmZ/XcxqYkK3 MbbX5vyOszDFKR4rf60yO9FPAhHhBmYOQsd9RvRqxHP/yCQA8IhI6fyEKj0CWSDnQ3Cn gITKSYh73k5nRTOLswQ7QGYdKTfdN2z1sdEM4lpdsyvfv2VbHLJXriVnrCNYcGWDqkx1 Tsiw== X-Gm-Message-State: ABuFfoh1ND5oh+M+vMo1hhT+TN7XLSc0iQryjvuanqDxbv3cWDQJVMrp kuG/bxmWDm/ktcUyjfZMccFIVN8rq24= X-Google-Smtp-Source: ACcGV63mr+VBG7dApN6UMb3L7cnnwx16qC1CfBEYeU+kD0XuCM7XDnd5rF7MmfrEpaN3oujjS3SFbA== X-Received: by 2002:a05:660c:1c2:: with SMTP id s2mr2749345itk.127.1539808640767; Wed, 17 Oct 2018 13:37:20 -0700 (PDT) From: dana Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: [PATCH] Clarify documentation of parameter-assignment behaviour Message-Id: Date: Wed, 17 Oct 2018 15:37:19 -0500 To: Zsh hackers list X-Mailer: Apple Mail (2.3445.9.1) Someone asked on IRC if it was 'safe' to perform an assignment like a=3D$b= when sh_word_split is enabled. I quoted the documentation where it says that = the RHS is always expanded as a single string, but then i realised that this = isn't actually as explicit as it seems when it comes to 'splitting' features = like sh_word_split. Consider the following: % a=3D'foo bar' % ( setopt sh_word_split; b=3D$a; typeset b ) b=3D'foo bar' % ( b=3D$=3Da; typeset b ) b=3D'foo bar' % ( b=3D${(s< >)a}; typeset b ) b=3D'foo bar' In each case, it's not unreasonable to assume (IMO) that the value of b = will be the result of *splitting and then rejoining* the expanded value of a, = similar to what you'd get if a was an array. But that's not what happens =E2=80=94 = the splitting operation is effectively ignored in all three examples. To get the other behaviour, you can nest the expansion: % a=3D'foo bar' % ( setopt sh_word_split; b=3D${${a}}; typeset b ) b=3D'foo bar' % ( b=3D${${=3Da}}; typeset b ) b=3D'foo bar' % ( b=3D${${(s< >)a}}; typeset b ) b=3D'foo bar' Hopefully this explains it without being too confusing? dana diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 9ad228679..4fabbe5c5 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -54,7 +54,10 @@ indent(var(name)tt(=3D)var(value)) =20 In scalar assignment, var(value) is expanded as a single string, in which the elements of arrays are joined together; filename expansion is -not performed unless the option tt(GLOB_ASSIGN) is set. +not performed unless the option tt(GLOB_ASSIGN) is set, and the effects +of `splitting' features (the tt(SH_WORD_SPLIT) option, the = tt($=3D)var(name) +expansion form, and expansion flags like tt(f) and tt(s)) are not = applied +to outer-level parameter expansions. =20 When the integer attribute, tt(-i), or a floating point attribute, = tt(-E) or tt(-F), is set for var(name), the var(value) is subject to = arithmetic