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 2678A242B1 for ; Wed, 14 Feb 2024 01:46:56 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707871616; b=rnWr33mP1HEsaamLV2UQ5xHDndinirLNpK4UBwUYWw4ndO9fbJxicXyra0ApmQ02CBtNmi2Yos V797i8NjDrkrRKs+s3xeKOy/JtMnsFFa5uhdRfE7Cv4sD3vs8ryFcHU31rHoI7ShugnqdJ21PS 3Ubes7RPVLtJGvoZ3Dz9ZADIlr9TcGMFOss5ps4/XH9+Uh8NlxQHDvH8yT8bBSb+X/6yaRHBaC sQv8uZ5U6NKBogECLRvPw/KNj9vkUXoVZlUMtD7/JrdyjU99t/Ywe4at5C7c56xHoQNHshNmSJ /jFmSJttgOv4jMIHy6ijPGps6O73H5Y9Rg6OzcBPM86RpQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f180.google.com) smtp.remote-ip=209.85.208.180; 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=1707871616; bh=Pu5txzUUbSKlpAa1CUogsU9EGJu/hQsbQ5jHhOAPEHg=; 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=eIGD/8qnNKgNvqTl6h/soeCdAKnM73fpPttF6WAqUzSWGyD5R/5WXP++fDuPylfJ6RhPPcmdeS TZodsHUqMJpRv5gYKufjWNVJJymDiw1k1ByOjMInZvooXYh/J3iAp+JOPuLWxghiR5nTLC7U/U PdLjIF2vu3G1R3HBeBYR2nr76GKiSR4eRvorCB2Z6ksLaD+mVg+r3CHbaLe+aF8IyOgnVt5VDN /zouk8brSpFbIRqLUfkqMO/A1VYxpeL9WGJLlsOtPdieikekp/9A0KROSK56QsIpTtSiwftR59 Spczq7weF359pdxkXc3H2nJ7Yt6DeBbAH2FJG3DbE8PFkA==; 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=8JteAX0FeKl2l8ek/YoWGicYWawHOg2oXIEhq8VBVxE=; b=hWV/AuCTca/GY94OwkCOnueTer FpMWskJaKsDzesZ982E0A1CWi1mOZSpG0mIhkTeFpVglJho6pZNmWvozacd6nf1PK62acXXYTop9n zx/9O5ydXVoxd5HoWytVJCoh5U4m5zr6MTnTK1CMr/xwD/mQflUCZ5br2PvnW7DYq9HGrb0WjOIVl Jd+qOaqpiPjsyeUkWL+YQxRZ5LtAH7GzBu7JS3jxIzyaUWkcWRsbiNNVcHOl71FswxWjc2U4Z4Tdn jLNK1D6CXyS5OHqIRa2RFkR/YLbcdLNH1aLyKodTpPKbkHiummAsw06gd0Mjid1Y/lPfTHxUsG6oT 7pir2PNg==; Received: by zero.zsh.org with local id 1ra3QN-000P2Q-PH; Wed, 14 Feb 2024 00:46:55 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f180.google.com) smtp.remote-ip=209.85.208.180; 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-f180.google.com ([209.85.208.180]:58453) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ra3Pg-000ONg-Fz; Wed, 14 Feb 2024 00:46:14 +0000 Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d0d799b55cso62232051fa.0 for ; Tue, 13 Feb 2024 16:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707871571; x=1708476371; 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=8JteAX0FeKl2l8ek/YoWGicYWawHOg2oXIEhq8VBVxE=; b=G1gCYJEYgeGMv2an0djTQGB28388yTCYmFxjxY9BG2UycGF15a4Pk6XpXKdEkFNY2L vz9HjiMuDmQS27A2f+/mv2h/vVnPMjIExObENqUFp0zUoiXrhNIsUO4FTA/zxvSONxv3 cydmO60EjVIZEmXlkQKNXBIwszt5YncV73iUJkrqn/BM/ndYhsOlhTanViFNKKzPqXUx qhb0Km0nunESCAbGCkRkH2yh6HmQECLdvklwhRLgWQWMscniMQyO3oiBv9icjsuqjjzG 6UuGcyzfiEBS6HobR6F1HjF/rZxpov3BBLlfjsOjahmkq5Vp49J6mvSSCtBjOybvOw05 lJ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707871571; x=1708476371; 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=8JteAX0FeKl2l8ek/YoWGicYWawHOg2oXIEhq8VBVxE=; b=wD2MK96altaas6ptCqryx7ZPTUirjDZttW37jtjXI0yIODXi/1J3Xj1nUsmoOr0d5/ QzhqUcSnnZqaWQATaiV82/e1dVq1YWi9MnVnSOZ4yVxmvJKCMDyqNV9ZpU5d7Q1QEzjj 4ljmjyrpj7aTp80SgZCHZ+Zf4qMXLxDIiwnS1w5XXfIvDgPvrcxhxe44UhfXBlgjtPuc 3t/jHhg/zGVLtZ+2VYKkyw13fpS1LIczK9ypYW1hNCLz5lamyACdoUHLRbJub8+hij9a pQ+0Yoy/qt/eSUSTQTNSUVyt39/5/x9v/n+LYiauso8SJn7otDR5WT63Vh07MGeoZj9e YeFw== X-Gm-Message-State: AOJu0YxolhrFSMx2ZcBNBDsqJk/TEjJyWlKyz2JuL7mhbRBHcdYpixan iDukhexvncgJrRL5T2CSEhUMUsgodmbFOq29DlVkBBYT9dw4XtH/uiF4cPC6EygkP/BjRD26bp8 MjKhZQo+60VyClaBaAw9Wi8u3P6rfCfLB X-Google-Smtp-Source: AGHT+IEvURraCAPyPYnFV+eiCgaUsTbM+JqCmktLsNOU8WtZbUt5V0GVxo2CZPKyWGMh2eJqJCVhiWFwEzfnBINEOJo= X-Received: by 2002:a2e:22c5:0:b0:2d0:5f2e:5b35 with SMTP id i188-20020a2e22c5000000b002d05f2e5b35mr915765lji.30.1707871570761; Tue, 13 Feb 2024 16:46:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Mark J. Reed" Date: Tue, 13 Feb 2024 19:45:58 -0500 Message-ID: Subject: Re: Counting characters in command output? To: Zsh Users Content-Type: multipart/alternative; boundary="0000000000004c1c7506114cd64b" X-Seq: 29666 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: --0000000000004c1c7506114cd64b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 13, 2024 at 3:41=E2=80=AFPM Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote: > On Tue, 13 Feb 2024 at 21:39, Mark J. Reed wrote: > >> I thought this would give me the length of the string, but it seems to b= e >> counting words instead: >> >> zsh% echo ${#$(echo hello)} >> 1 >> >> Is this a bug? I thought I'd need a modifier flag to treat output as an >> array and give me a word count, while character count would be the defa= ult. >> > > 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! --=20 Mark J. Reed --0000000000004c1c7506114cd64b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Feb 13, 2024 at 3:41=E2=80=AF= PM Roman Perepelitsa <rom= an.perepelitsa@gmail.com> wrote:
On Tue, 13 Feb 2024 at 21:39, Mark J. Reed <= ;markjreed@gmail.c= om> wrote:
I thought this would giv= e me the length of the string, but it seems to be counting words instead:
=C2=A0 =C2=A0 =C2=A0zsh% echo ${#$(echo hello)}
=C2=A0 =C2=A0 =C2=A01

Is = this a bug? I thought I'd need a modifier flag to treat output as an ar= ray and give me=C2=A0 a word count, while character count would be the defa= ult.

Process substitution gives you an array. Quote it if you need a scala= r.

You mean command subst= itution, but thanks! It wouldn't have occurred to me to put quotes arou= nd it to change what the `#` was counting!

=C2=A0<= /div>
--
Mark J. Reed <markjreed@gmail.com>
--0000000000004c1c7506114cd64b--