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 4ABDC24BB9 for ; Tue, 13 Feb 2024 21:46:34 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707857194; b=k4/pvyNaK5KcEIi9tEr8E+7PIF6TZSNVk/1tKjOAVhmOPo9Snnv8tbIcRu2PZH+pCYDztA4Kmy DZclhwMBHIImTuoF43Gc7ZTxN+ZVVDqHjVTCE/c+kd/6JMgdJKOVQDQa6bd6IP6NDmauz2mGNi 6qdN23VCzl75RZY6t9qR0T+rRjNjFNNdGlXTSQoGAtb9R+fyhuxLp+ouTbHX8EHlI7pAAaa6Es NrJCQsdwuF5UiuJvJYqNCRaVT2UgIoKdfdeTerTUxwrok/Vi6irUisac/rQrSAIpNQ1zEnegiS HL7ZqeGUWr6wE3KYVOsygz8t+Z51yTFnvpZuE3pwp0q/hw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f169.google.com) smtp.remote-ip=209.85.208.169; 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=1707857194; bh=xYpv39MZKqHIjWpzv9YvS++MR+PM8yNmupkkAEYqXmE=; 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:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=J1jygFBuboFYl5TYVGdHf/S0pjgvBu1eplPdPa8xexWJ3S3xO2J0E8PetVOJIx1znMp1Esjjww WvTXrUVL3kpI+YBPfDA1hjGrGInY/uUEkDhkGO7IVoux20gdqE2AnM5qNkMw6l5yFNbuS+DbRb PScifSV8PJ34/c43euYFTUK8znJQUMcrRKAS/311MSEtC5yszWC8XykQ5w8U/Q9HaxyxpH56JE TDN2KJfCNLOO42bwy2xqXCKeiuK52PVNb2TWVunLQtZj7M6DoNLJAEx8iQ7xuDBFUcITOtGloP XhlEQCq2dpi/+0/t+L2bgUiKwSs12CVAo8a9yJRV1PDfzQ==; 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:In-Reply-To:References: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=j4X1BlexzDAq053jJfybJOtX0QJNZxj4SepvQ8kqzkk=; b=raSU6Rvl2vj2qTcA2D3WQ0gByr /654rFU0txlXekbyy4183sqV9rNhp0EcaLETjDe3iI1k32QLlkJNloDhOgaa3et/MmmW/yklNzmzG DdlO8xuyy+sm0zBy37/Oc3dTSGFcQjkSTXeoDGI0jLZeJvCFBXDWNNcuvC5b5V39CZekWsb/DRBzH /vWgDydP9KDRgzl/IbdnObcXwXuNiWHFx/IRsUL5D7EdxCmhl4bfdqPRGWs35O4fMw/ae+ONgcChr enLQIdw98lP8lFAx1s9dP+ffXltFlABIfMTdU5VP5hECh5L19UHTUkhWEQkt5hOOpJG1mC2iHK7l7 gZVwjmDQ==; Received: by zero.zsh.org with local id 1rZzfm-000IPM-Nt; Tue, 13 Feb 2024 20:46:34 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f169.google.com) smtp.remote-ip=209.85.208.169; 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-f169.google.com ([209.85.208.169]:47105) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rZzb1-000HDp-RA; Tue, 13 Feb 2024 20:41:40 +0000 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d0e520362cso14440241fa.2 for ; Tue, 13 Feb 2024 12:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707856899; x=1708461699; darn=zsh.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=j4X1BlexzDAq053jJfybJOtX0QJNZxj4SepvQ8kqzkk=; b=c2x0jyAHHC3gboi7dg9bAeNT4jJ9jmGrERnyh3usqF8WB6Ud3tBQB32WzeFmrppMS6 EYOmVCbIuaWLpEgdJN5UjVBJN7vLrI+sP+Y4gd1RQ3fpMKtuB8nSyQiWhjMYghYWaBOs 0ChOq1MsELoCs9gcGHlawqpKYPVlDlWGgOH4GVtXhniAevzLirzVG49/u0TVdOmZ7WOf Quq0iXEtJPJdVsVbAGtLCkY6HtbcWw04lky9LudJPIRRwt5rGOSrhUnAq4c0vkfSA4Pc DhsTpqhsz+ROBOQ2tMOCQse04TkImzAd81/8J3t0ZeIS6rHMXmurNSp4qphMIM//Ufge OIfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707856899; x=1708461699; h=cc: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=j4X1BlexzDAq053jJfybJOtX0QJNZxj4SepvQ8kqzkk=; b=JtluPYwFAY19MB4rQFyKDCBRucTj7ru+amBfCuAuExXhCYWK6GdX8oHHDmwD2hPgmm kIy6dRFv/ooe+QQ5puZXfMRs73XdHO/xHBZWOA+PUfzXZm2Nty0Dj64v+T5oYchKvsY1 +ongnDyMwYOoZBdW0NHmj7aLIke+zU3GuWqBFjGHpunHskXtgBF2dacLmWYWDklou/zk oZ+p/oXvJrQpso4XpVlYJ+J+Guo3TAT0bu0xIUdfvByKh4x/VgS3z5GoDXvYi177V5IT RwmetI+nMOswVTQ8Dgq++Tj35/spllDblDu5qpxW0h1haukMNhoPJd9nrTiLN/Z5jzCZ uu8w== X-Gm-Message-State: AOJu0YypHu7rHKUIzMlA7epY6fmobAJGtj11ff98wKJ4T6idLq4vL/h4 iuyPtYrXnuILP3l29sb5TGe7gWX7pNMKyBdEiBR2Io2l13AeC9Q5FKDvaGF2FFEulIhoSMYhlzE 7J0XbFPy+R+hB7s00Xdn3qClIf0o= X-Google-Smtp-Source: AGHT+IGjh9+UvnBlszho4cnnBXArG3E8zM5a8tg+6ueys+APIDEMKzyxSgMslQXIIdlNbcDKTXCm9xRBAAx5HLsA4vI= X-Received: by 2002:a2e:301a:0:b0:2d0:ce22:5174 with SMTP id w26-20020a2e301a000000b002d0ce225174mr512700ljw.42.1707856899021; Tue, 13 Feb 2024 12:41:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Tue, 13 Feb 2024 21:41:28 +0100 Message-ID: Subject: Re: Counting characters in command output? To: "Mark J. Reed" Cc: Zsh Users Content-Type: multipart/alternative; boundary="000000000000cb225b0611496b01" X-Seq: 29665 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: --000000000000cb225b0611496b01 Content-Type: text/plain; charset="UTF-8" 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 be > 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 default. > Process substitution gives you an array. Quote it if you need a scalar. Roman. > --000000000000cb225b0611496b01 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, 13 Feb 2024 at 21:39, Mark J. Reed <markjreed@gmail.com> 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.

Roman.
--000000000000cb225b0611496b01--