From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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.4 Received: (qmail 22593 invoked from network); 19 May 2020 23:55:12 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 19 May 2020 23:55:12 -0000 Received: (qmail 10013 invoked by alias); 19 May 2020 23:55:03 -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: 45857 Received: (qmail 12059 invoked by uid 1010); 19 May 2020 23:55:03 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25814. spamassassin: 3.4.4. Clear:RC:0(66.111.4.29):SA:0(-2.6/5.0):. Processed in 0.724535 secs); 19 May 2020 23:55:03 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddtkedgvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdektddtre dttdenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdr shhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepfffhgeettdeukeeuhfduvd ejveeftdekteejtedvhffhgeekvefgvedtleffgeefnecukfhppeejledrudejjedrudef gedrfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Cc: =?UTF-8?q?Markus=20N=C3=A4her?= Subject: [PATCH] vared: Escape empty elements of arrays Date: Tue, 19 May 2020 23:54:25 +0000 Message-Id: <20200519235425.13713-1-danielsh@tarpaulin.shahaf.local2> 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 --- Found this while replying to Markus. The %prep block is copied verbatim from several other Test/X*.ztst files. (Some of them do the zmodload at the end, but some not. I guess that doesn't matter.) Cheers, Daniel Src/Zle/zle_main.c | 5 ++++- Test/X05zlebuiltins.ztst | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Test/X05zlebuiltins.ztst diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 8c0534708..2f6a53a40 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1721,7 +1721,8 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) return 1; } if (v->isarr) { - /* Array: check for separators and quote them. */ + /* Array: check for separators and empty elements and quote them. */ + /* ### TODO: should probably use quotestring() rather than reinvent it */ char **arr = getarrvalue(v), **aptr, **tmparr, **tptr; tptr = tmparr = (char **)zhalloc(sizeof(char *)*(arrlen(arr)+1)); for (aptr = arr; *aptr; aptr++) { @@ -1763,6 +1764,8 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) *nptr = '\0'; /* Stick this into the array of words to join up */ *tptr++ = newstr; + } else if (t == *aptr) { + *tptr++ = "''"; } else *tptr++ = *aptr; /* No, keep original array element */ } diff --git a/Test/X05zlebuiltins.ztst b/Test/X05zlebuiltins.ztst new file mode 100644 index 000000000..1bf7b18b0 --- /dev/null +++ b/Test/X05zlebuiltins.ztst @@ -0,0 +1,22 @@ +%prep + + if [[ $OSTYPE = cygwin ]]; then + ZTST_unimplemented="the zsh/zpty module does not work on Cygwin" + elif ( zmodload zsh/zpty 2>/dev/null ); then + . $ZTST_srcdir/comptest + comptestinit -z $ZTST_testdir/../Src/zsh + else + ZTST_unimplemented="the zsh/zpty module is not available" + fi + +%test + + zpty_run 'a=("foo foo" "" "bar")' + zletest $'vared a\n\C-xw' +0:vared: basic quoting test +>BUFFER: foo\ foo '' bar +>CURSOR: 15 + +%clean + + zmodload -ui zsh/zpty