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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,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 2fa26c0d for ; Sat, 9 Nov 2019 08:12:11 +0000 (UTC) Received: (qmail 5803 invoked by alias); 9 Nov 2019 08:12:05 -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: 24413 Received: (qmail 6990 invoked by uid 1010); 9 Nov 2019 08:12:05 -0000 X-Qmail-Scanner-Diagnostics: from mail-vs1-f44.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25622. spamassassin: 3.4.2. Clear:RC:0(209.85.217.44):SA:0(-2.0/5.0):. Processed in 1.747222 secs); 09 Nov 2019 08:12:05 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.44 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pwxQLBe0vyq4gpXfV7hQa3mYm/4q0cY5eWKH4xmzIeQ=; b=TTpkLsC0kEax3swJGDjvk6XnN6SJKNOutK++It4MgJlXnFaa1XbO2lay5LZDJAbq73 AobD9QoPdQzHzKiOhvKA9teBjLrPN+uXN4IdBQ5wGLEgZ5dWVOvdfqdHB9pNNoTltrY8 PcJYmjI4HE76/mx/KlKdLTTVU9LzR3F3dVlj/PA+VqfCF1WvymwM0KWjmJUVRXLN1oMI Q6j5tlYpUrh7Gj044mgb1IzqhEg2fhT/1+EDE85FpgFKeYXvdsn0Ev9BvXZUdJE2IX5w tJ8RJJTIE/xsLFcXZpp2EpvoEwPSnbTj73o6xv4m1gkQD2VwhJ3atVqsrIcBMShfE9gH nZng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pwxQLBe0vyq4gpXfV7hQa3mYm/4q0cY5eWKH4xmzIeQ=; b=mvkaqNexSwxz8AjIYGboCOIIJCXjFBpwhnmD/t/uMycp10ORxT+DMZokPxruka4g7H 4xi1qvbfGljHMHshQVhkOInYYkhVid1ihlY6VttRaQYYu8o75k4L7qHtG/atuzaaHrlW p5J/NBtgk1U+9hX6fLEAuThYOhkcyoqCAp0fcZ76pyxc3MG2weg5mBJxLEo2qZu0bWi7 1autqWb33z8KNupllaiM3SYqHHabVpu6o3lDTdkeCfsyqeokevQGtb1+Hl/Q+jLfzX3u lKt8scKYvf6cnsdcEL2EZCB6eyl0b/DF2gX3zCFJItsPV267mXXFJBSpWdhWwdynM3WY 7naA== X-Gm-Message-State: APjAAAWH3m4ugwNohOxpXirOKl3VMGR1tQu3wTfQyy5ise6jQ7JwDMhz IFzVb+jhwCtPKLUz0avIfi4Hwy0hvU78N6A9Emw= X-Google-Smtp-Source: APXvYqwPhGxQB+sM0dt5/3WoQvUNDv1GMURGHc/StBUgNLh8Ij0Jmehn3GkEIPozDjZEIxHruN4LfiF1tgHcsYOM6Ss= X-Received: by 2002:a67:d31b:: with SMTP id a27mr11643261vsj.215.1573287090237; Sat, 09 Nov 2019 00:11:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Sat, 9 Nov 2019 09:11:25 +0100 Message-ID: Subject: Re: What's the reasoning behind z & s returning nular for empty input? To: Roman Perepelitsa Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" On Sat, 9 Nov 2019 at 08:50, Roman Perepelitsa wrote: > > On Sat, Nov 9, 2019 at 8:27 AM Sebastian Gniazdowski > wrote: > > > > Hi > > arr=( "${(s:,:):-}" ) > > print -r ${#arr} ${(q)arr} > > Output: 1 '' > > This makes sense. Consider how many elements we should get when > splitting a string on commas: > > split ",,," => 4 elements > split ",," => 3 elements > split "," => 2 elements > split "" => ??? > > The last split could give either 1 element or 0. The former is > consistent with the rest, the latter is not. Thanks for the analysis. The additional problem is that quoted but @-lacking s-flag should still elide the empty elements, as the manual states. So this is an intentional exception and I wonder why it has been added? -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org