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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8320 invoked from network); 13 Mar 2022 19:23:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Mar 2022 19:23:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1647199436; b=LyqOX+NG5aPyFEerthRoeCnvEY4AoPCsm/LSGskMH5FjXyPBfqv9bEW6/rqHW5aQwwTMikKqDa YlTRU9MsE9e86mMg0XNauWeZy7V1emCbgivFg/5zQMUgsZDZPumjJHHkNsuRSfcikf4tm7CZM5 y/jmaZrTNI9IktOpuSmHP5EO7AbEYSdio0jSXBlxwqiSaCNYMPVgpr81mwhlJ556FraqqtlreZ EC3QU1EMCCd8jIFzdi9RdV8bMf3xzdpY2w5tQQNq0P1TjwJTZH1UnKdjoYY86D8s2iM5Yv4ATT VVq6wpMUk3A77FC7g46FhLpj/Y5+FuxEjUHZ+NNjW5+xrA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pg1-f171.google.com) smtp.remote-ip=209.85.215.171; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1647199436; bh=sVxlnGzzH8+JN+xSlWgHBVp2oN5lKqQ44LwkM2P8KVE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=fyFj5F6oX5nO3Of07c14Sx8UzBcdIUN0x/0R+cY1L1mqPX+V1/Q2m7R3S/aEpmN4GbgEYG+EBd xj1GVIjOvARZ+1AAaLx5pezEz3l2+NqUqO3ZOqwnRzmTOGPg1ONlS9O/GsjCuCmtVychetAO7z D5+btoyqJ1VrFHJnfTMk7CVjYfUXG2walPNhIJRwtUjQSywEiH1+/9w+9Q4u9ic1QhO6d+IEXK /PL8pPwLDzZPAjlhtnRXuWTg+9FUyGzHahG20zvK80ycq558l379+hv1sp90Ji86M1jqseYz32 HaQ7NR06+elflyA5tCvk8RBQFXp1TK4bDl4oxCS6yHKpWA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:References:In-Reply-To:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=/ppV1dX+GQ/zDpPx19m/X0swlaKVmpKzklaOZlLREAE=; b=jsChkJE3nwYR9JJa/pnZ3MandH qRKGfIJ+wv3L5DKpP1hpbX2X/4fxouW8cpoAyoki26ycRhJGiaZmusvBU9GiHCKpt1s//YBK9MDF4 ZYYPD9JVjL6wQKgSDvLDH9iqVNQxcAmg9j4PL71Wp+XigYkqVOgjKZ7VWyECoxasRCWWfoBDqrKAs X9DZwvz1XEktRQEskWf8NUxrJOHx5DVFPKV5ttoeYIpF8B0+db1DePArSnZIzltq7DADBpo/hQFdW GMrLVVQ/d1sBm2MYPhXK09iymU0CmYjRJERPZ50lpVlw7oXLe/RPEI5JbpZIMLJVi99PUnSoatz9g XAMlph9A==; Received: from authenticated user by zero.zsh.org with local id 1nTTop-000A3z-Dw; Sun, 13 Mar 2022 19:23:55 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pg1-f171.google.com) smtp.remote-ip=209.85.215.171; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pg1-f171.google.com ([209.85.215.171]:42891) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nTToH-0009lD-Lg; Sun, 13 Mar 2022 19:23:22 +0000 Received: by mail-pg1-f171.google.com with SMTP id o8so11975004pgf.9 for ; Sun, 13 Mar 2022 12:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/ppV1dX+GQ/zDpPx19m/X0swlaKVmpKzklaOZlLREAE=; b=Iw34GmTawenqRSpyMmLxLAl5zvaXwoaoMxWV8U9A8u+XEonZqeViWxXSGOyV/tS+kq hTQgfF1JEKgY2RNIKl2pm3ZqoNu7HS/gTVpEsDARiLPMYJO4A60pmRF2fuA9aTnPYo4+ S44mJQd2s4/tUFQK4NMUOKtguVMLyY3NdaVh64cTIUf3XWsfAPxDCAn8LrYEDasf+MDs t1XjqSTJn0/PF/DZk5I41Sac0YPMEzDQ4tV6tVBWnicOUF089EsUU+7gcnHbMRGn/9DX I9OEoiC0eWG8OCcrSm+hMs347nOGgZEaV8Yfn7Tw94rjM5seUbDBtPfCI/S+/6PrOLry aTHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/ppV1dX+GQ/zDpPx19m/X0swlaKVmpKzklaOZlLREAE=; b=TOn/uqmv+Q2D/4fD5R4u942wGql9xiMGD0s5y4mtE/OTPlzBahkmumxVHl5PLEeaJj jJr5DZseTgc2dwhVaHXPaA6XYhcvBreeIBPjkumDm3yGQSeheC/pGhR4zD86hOPLOKQD dVg4q50z7bLeijfto40/ShCT8Xfn0GqMGzG1+RCzQg4pENv7Bx8pXI3cNEFoDgj7OBL7 bgqdl/9wLu96tpR+VRajLqTUx7pS7gfwG8PRzrvF5SextpD4lwMCw8UNZsVotmPCptqH z/YEGcWENdIo779++6vXI/qUOkR0wmbEemFDwYNDkYKPJJ5VWzdefl8ZiNh3R5crCzkb yZVA== X-Gm-Message-State: AOAM532hsshyHNNNTt4RyiM90KmtppYK+4ZwF7rNsKKDBTUuLgZFwaOP wV/Ac2kihYFQQPJIScmzWBim5DxIqGteBq0o9UtCTrJl X-Google-Smtp-Source: ABdhPJyMcP8Xic8eRKx+smQX0lAl+4pbdQuRcIKIQxfDneFYvwmj4Ukv+VFC408XD31nasD+jjPGxVXTd0HZqMspUzU= X-Received: by 2002:a63:9043:0:b0:37d:92b9:aa6b with SMTP id a64-20020a639043000000b0037d92b9aa6bmr17401718pge.406.1647199399914; Sun, 13 Mar 2022 12:23:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6a10:466:0:0:0:0 with HTTP; Sun, 13 Mar 2022 12:23:19 -0700 (PDT) In-Reply-To: References: <20220310075026.ovwlhxq24cmda5s3@chazelas.org> <7694652.296620.1646922350773@mail2.virginmedia.com> From: Mikael Magnusson Date: Sun, 13 Mar 2022 20:23:19 +0100 Message-ID: Subject: Re: "${*:offset:length}" and ksh93/bash compatibility To: Bart Schaefer Cc: Peter Stephenson , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49837 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 3/13/22, Bart Schaefer wrote: > Arriving to this a bit late, have been traveling. > > On Sun, Mar 13, 2022 at 8:22 AM Mikael Magnusson wrote: >> >> zsh% a=(one two three); echo "${a[*]:0:2}" >> on >> zsh% bash -c 'a=(one two three); echo "${a[*]:0:2}"' >> one two > > The [*] subscript in double quotes has always been treated differently > in zsh. You need [@] or the (@) modifier to preserve array-ness. I'm > not sure the presence of the :off:len suffix should change that as a > side-effect, at least not in native zsh mode ... and it might be > difficult to "notice" the suffix early enough in the expansion code to > cause that effect anyway. Particularly without also having the effect > that the end result is not joined into a single string. The way it works in bash is it does become a scalar, but the subscript works on the array elements before joining (just like [1,3] does in zsh in the same context). I'm reasonably sure that there would be no difference in the zsh code for handling $*:X or $a[*]:X, other than having to add the extra faked element for X=0. I think the correct answer is to always have :off:len work on the array indices if they exist, regardless of double-quoted-ness... But I also just took a look at getindex() and don't want to replicate the appropriate parts of that logic (which would require understanding what any of the parts do). I'm also not sure if it matters too much since it's been some years before anyone even noticed it, I just (somewhat naively) thought that maybe it wouldn't be too difficult to add... -- Mikael Magnusson