From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 345242150A for ; Wed, 14 Feb 2024 14:57:52 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707919072; b=kpZUjwcrsgup7duxmosFQbCngqtY15MuwjQWHKNuPiZ6Bw4W8+AxoDdPv13/9psSWHLatByTHQ fP5NK9iCgtd3MKsHQ8Myj/i//jzu/SRQHoSi597PXKqXLNmRlGsZqWi7cHhDohzx8Ir8q9I1n+ SYbJZLZunW6Ztki7fwp0+ycJ4S1ETMf4xH9w9mRa1Qj2okWMPqtwqHn8tb+44ZXiJk/ebswA3N OUigdv4BwW4b3XHwyhP9vzK2Y0xrDwIPT+TKa5OIBGnLxRctNCJh0zREogjd0+TeDuo2gdP5dU i78eG16PH/FCzHu5tcJ0ZZfspr6VtY61a4Ac/Uo11BT3Cg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f182.google.com) smtp.remote-ip=209.85.208.182; dkim=pass header.d=gmail.com header.s=20230601 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=1707919072; bh=FvOrAG67UpPq8ui53LqdskG+NHNxIk3wxaJpJHNAS2U=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=XCx1VhkBQFCYHpIg6V5UginZDWZqZWQ3F8uMK0MkPD0pJleO+IG9DFQdErPVf9QRNety2mG0/U uABmiB35pSBsWZP1A1Xo7DKmeXm/iBxWolOmNQh3UMRUJjKCNXsRygHr6xghtu5WqmYu0go3k/ bt+DcSJDoHLZeEcDjj47aqQqOcBwsKnWR/jjNAxeOTKpdLCKaZEp8MzB/Jnsw7y+l3RJYQCzuG yQFk3ny6UzoQI0Ps5oLIa7ymR/WgNBiykwiVBvpEe5Ur4fIWd7J9//V1wkx5TbJjA8wdmcU6vn NFJaUR+Swbn/erec0GFuZj+81fvvQJ4Yevr74cBlXIAjog==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=2mT3K+pHbI7xLPkM1vXx1oa5gcsBN0a5/UWRnNm2Q4A=; b=CDGuvT1Zlgg3GpxR269LUCzFUe hHJ8X5e5ze5wWc/FGeL35zRgAlAKSzHmJ+numwFeW99W2vjSIz56+S0NsYj+jgDrYIvNFrdFlyjO7 ekv6Hr4k7qH4eFS+svlvnNKucdtTW3KS9FJP0nG5MpdldaHpOtc1ElayXuyzgIt2cMpAl7x59xw02 PydaKbVtd1M/EHvl9V2giPzJhgEJ9XVwWrzfIpf4nz8nHC/St/JfY2NTSneofh74kePxbmv6v5Zcm Jl+BJG9gcGubMlyp1xbm6Yvzpkjt3FxcI51u+kEcXst4n38OJmsf+ltjagdH44F7BiUzRQ5lCyBW7 5d9PrXYw==; Received: by zero.zsh.org with local id 1raFlm-000Lwk-JJ; Wed, 14 Feb 2024 13:57:50 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f182.google.com) smtp.remote-ip=209.85.208.182; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f182.google.com ([209.85.208.182]:52499) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1raFl0-000LGz-Fl; Wed, 14 Feb 2024 13:57:03 +0000 Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d0d95e8133so67528011fa.1 for ; Wed, 14 Feb 2024 05:57:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707919021; x=1708523821; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=2mT3K+pHbI7xLPkM1vXx1oa5gcsBN0a5/UWRnNm2Q4A=; b=HMiX/t719OP3X8BaKk1h0lq2J/sTKJb3gI22TK4v2v/S8qOQoOD8laC/lf2m5J645B JYFdQG/OmfOVz1LE+3kw2nX6gbT1SBDWlyrr7ecQnXQpOzih2wWlmAvmRjBcfgkMayhK TyKE9j7hrJ/vMpvzPLOhnjnAKzKDhENgit78RJiH8WLG8FKDapYaWNpfAqs2FPOj6hsY kIeysBYZ+i/mPeWZuACGfpbgrWuAsBkzo9lVZnMtxs/xb9mG1oRczM4FqXRTv+oI/jUm lcmMR1kMEwekTR/OvddlFer1FkScEYz/5NndxS5smwOpN8eZL/YDvud8j5FP+yssI9+H Rblg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919021; x=1708523821; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2mT3K+pHbI7xLPkM1vXx1oa5gcsBN0a5/UWRnNm2Q4A=; b=Zj2jZ9OyWlFkNS8rmcN5A5LcZH1gsvkIL4O3IPpDWgTr1fn8Bq3D30lagEDDLCi5Ia pJu5mqRoltpFh0iOFtFpyXwZzkGHJKuxWKmuWDG/gLSGTbV8W6KBdWdQ838ePB0lv4wu JFo0/fOpS/1OR4hpPTeZY2c0If/xeZ+OX7yghWBqVWVQklirN1l5tFDLbNFNNHH+nZEC FKXM1roYPV0QJonbysfHM+JzYQvqRaG9BDtahLacPr3Ipmtw9sp05JdsD4vwrHw8JPkl 1m2geTPwgCCR1ZDjHws6mpAqjhEeyx8PS4GGLZ5yahHEBiIpKhEG1hjlq1g0O7yrUSRr g4WQ== X-Gm-Message-State: AOJu0YxWwz6IdMtPXqJa7T1pn01ff8uuncB34utWqv+XkTlUIXrutmKj 2IkDGjj75xVwD9k+9Mz0UwN6SLbeV7EvhmqfAkwBWnRXTtE9fSESrW/4n3GnNf3gdiZ/B+Mm+1F pKiVWci0HzOC3y6ITJ5ap3H/MshfqYqdkB00= X-Google-Smtp-Source: AGHT+IFMAfKFlaX2FIXUbcGa16seQIal1Iqwx/HPqi92Z578AQJoGRCrXmlm7rrZed1+55I6a32Ej6m9CprCDXy0ILQ= X-Received: by 2002:a2e:980a:0:b0:2d0:c7a3:e971 with SMTP id a10-20020a2e980a000000b002d0c7a3e971mr2090060ljj.0.1707919020584; Wed, 14 Feb 2024 05:57:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Mark J. Reed" Date: Wed, 14 Feb 2024 08:56:48 -0500 Message-ID: Subject: Re: Counting characters in command output? To: Zsh Users Content-Type: multipart/alternative; boundary="00000000000086f5c2061157e289" X-Seq: 29668 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --00000000000086f5c2061157e289 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I think splitting vs not splitting could go either way; there are pros and cons to each default, and as long as there's a mechanism to do the other one, it's workable. But I do think it's a bit counterintuitive that parameter expansion is not split by default, while command expansion is. I would in general have expected *foo $(bar) * to behave identically to *baz=3D$(bar); foo $baz*. = In bash or ksh, that's true (probably absent some edge cases I'm not thinking of), but not in zsh. Specifically, I would have thought you'd need *${=3D$(= ...)} *to get the word spitting that you instead get by default. On Wed, Feb 14, 2024 at 1:49=E2=80=AFAM Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote: > On Wed, Feb 14, 2024 at 1:46=E2=80=AFAM Mark J. Reed wrote: > > > > On Tue, Feb 13, 2024 at 3:41=E2=80=AFPM Roman Perepelitsa < > roman.perepelitsa@gmail.com> wrote: > >> > >> Process substitution gives you an array. Quote it if you need a scalar= . > > > > You mean command substitution, but thanks! It wouldn't have > > occurred to me to put quotes around it to change what the `#` was > > counting! > > Right, command substitution. In my opinion, it's unfortunate that > command substitution in zsh splits on IFS by default. I wish this > wasn't the case. It's not even common that one wants to split command > output into words. Lines -- perhaps, but not words. So the default > behavior in this case is rarely what is desired and has to be actively > turned off. > > Roman. > --=20 Mark J. Reed --00000000000086f5c2061157e289 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think splitting vs not splitting could go either way; th= ere are pros and cons to each default, and as long as there's a mechani= sm to do the other one, it's workable.=C2=A0

But I d= o think=C2=A0it's a bit counterintuitive that parameter expansion is no= t split by default, while command expansion is. I would in general have exp= ected=C2=A0foo $(bar)=C2=A0=C2=A0to behave identically=C2=A0to ba= z=3D$(bar); foo $baz.=C2=A0 In bash or ksh, that's true (probably a= bsent some edge cases I'm not thinking of), but not in zsh. Specificall= y, I would have thought you'd need ${=3D$(...)} to get the word = spitting that you instead get by default.

On Wed, Feb 14, 2024 at 1:49= =E2=80=AFAM Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote:
On Wed, Feb 14, 2024 at 1:46=E2=80=AFAM Ma= rk J. Reed <mar= kjreed@gmail.com> wrote:
>
> On Tue, Feb 13, 2024 at 3:41=E2=80=AFPM Roman Perepelitsa <roman.perepelitsa= @gmail.com> wrote:
>>
>> Process substitution gives you an array. Quote it if you need a sc= alar.
>
> You mean command substitution, but thanks! It wouldn't have
> occurred to me to put quotes around it to change what the `#` was
> counting!

Right, command substitution. In my opinion, it's unfortunate that
command substitution in zsh splits on IFS by default. I wish this
wasn't the case. It's not even common that one wants to split comma= nd
output into words. Lines -- perhaps, but not words. So the default
behavior in this case is rarely what is desired and has to be actively
turned off.

Roman.


--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--00000000000086f5c2061157e289--