From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=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 33b56898 for ; Sun, 12 Jan 2020 22:30:19 +0000 (UTC) Received: (qmail 11613 invoked by alias); 12 Jan 2020 22:30:11 -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: 45287 Received: (qmail 5974 invoked by uid 1010); 12 Jan 2020 22:30:11 -0000 X-Qmail-Scanner-Diagnostics: from wout1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25691. spamassassin: 3.4.2. Clear:RC:0(64.147.123.24):SA:0(-1.9/5.0):. Processed in 2.852904 secs); 12 Jan 2020 22:30:11 -0000 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 64.147.123.24 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdeiledgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgogfeguddtqddvjeculdegtddmnecujfgurhephf fvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghf uceouggrnhhivghlshhhsegrphgrtghhvgdrohhrgheqnecukfhppeejledrudektddrhe ejrdduudelnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurghnihgvlhhshhesrghprggt hhgvrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 1/3] zshexpn: Describe parameter elision and add some introductory prose Date: Sun, 12 Jan 2020 22:29:26 +0000 Message-Id: <20200112222928.25546-1-danielsh@apache.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmail-Scanner-2.11: added fake Content-Type header Content-Type: text/plain --- The three patches in this series are independent of each other. Cheers, Daniel Doc/Zsh/expn.yo | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 9451fa605..c129b4228 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -582,7 +582,25 @@ and subscript notation to access individual array elements. Note in particular the fact that words of unquoted parameters are not automatically split on whitespace unless the option tt(SH_WORD_SPLIT) is set; see references to this option below for more details. This is an -important difference from other shells. +important difference from other shells. However, as in other shells, +null words are elided from unquoted parameters' expansions. + +With default options, after the assignments: + +example(array=("first word" "" "third word") +scalar="only word") + +then tt($array) substitutes two words, `tt(first word)' and `tt(third +word)', and tt($scalar) substitutes a single word `tt(only word)'. Note +that second element of tt(array) was elided. Scalar parameters can +be elided too if their value is null (empty). To avoid elision, use quoting as +follows: tt("$scalar") for scalars and tt("${array[@]}") or tt("${(@)array}") +for arrays. (The last two forms are equivalent.) + +Parameter expansions can involve em(flags), as in `tt(${(@kv)aliases})', +and other operators, such as `tt(${PREFIX:-"/usr/local"})'. Parameter +expansions can also be nested. These topics will be introduced below. +The full rules are complicated and are noted at the end. In the expansions discussed below that require a pattern, the form of the pattern is the same as that used for filename generation; @@ -594,17 +612,8 @@ noderef(Modifiers) in noderef(History Expansion) can be applied: for example, tt(${i:s/foo/bar/}) performs string substitution on the expansion of parameter tt($i). -In the following descriptions, `word' refers to a single word +In the following descriptions, `var(word)' refers to a single word substituted on the command line, not necessarily a space delimited word. -With default options, after the assignments: - -example(array=("first word" "second word") -scalar="only word") - -then tt($array) substitutes two words, `tt(first word)' and `tt(second -word)', and tt($scalar) substitutes a single word `tt(only word)'. This -may be modified by explicit or implicit word-splitting, however. The -full rules are complicated and are noted at the end. startitem() item(tt(${)var(name)tt(}))(