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.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,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 516D029A18 for ; Fri, 16 Feb 2024 02:54:24 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708048464; b=rytLChz9wqnpoV+xaVl0ja3n7zE8fWOvR1vcv78sa7RLSi1P0YMUZuhhU8/IIsVoQ8dIti8vpn 60iI7tTYiRiw2NMXKElHmBtQxGJTiPMaoEtupRH2LbDQW7nc/8brvGGiCcU2NKoMStRN390xPe SWPTgUgKEvxm7ZhpA8brrhUPwmbzxfOypBR6Mas+sUIWHqoXbgNDXkoqd9HgEuPKoZ6JI5lFJ8 sNdgYxHPB1cg7f2QXJ4FE3KaBx7tC4QUjpNOCZfxYpTgoz8LFC+ILZutRg5pscKB7xh/gcUUo3 Hn69sTGDGCGhc0Qxq3kdQVV+Iz2BV5duNkbwf8QdBmK/ug==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1708048464; bh=kZCVccD1Co2PkXYfE5UxEXdeyY2EwoxBeY7mVIlJ3Sk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=keiRPMQ2/yEoqeqTjVgPN396Xv466hcBVufJy/pvsCu8BdNmjLW5mSUrEBwZbu9KNYff0Gmshn VCY/0VSC0FmnIgWUCEDhOHCyNxbZpX7S/WZYJwKvh5un6cOyo/WxeRUlN6KbJuFsnawHBM5PYo y5KcaM2J+jqQ3aEwrin6DN0EidqB6bfYbaRdKWML8Pwmt4DTdmcwrA2VZ4y+cCvQTI73+jmHme WHKXtv1vqAiovH6ZQG0JVf/7cAD4C0MoL9IUpMHjZ5f6mmmqCggQKHiiW9YzKcUudsge7dqnU6 FoRqDANj8G9a+2kblPuldKRcaslPqW0EWnDsdvKhozIijw==; 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-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=IUDkYBtBRCZ+/pRW3fhQ4rVtLDVtEiwWsB5wpfdMamE=; b=TEFECIZZ+nGIShagjXtDmnmndP rX3rxyoyA10TukAuKuUpUNmeCeDBsA7vXI/RJveZ5yCWoObydsaZYF5SLcTHZuwNIu2IwBYQuAxtS G2VFfCyopB0gKy+6fTKQAJFWCe75XBLEUrFAN2/4rO5ufPRUi+eyy9GHlhyFVrB9DEErK8cvCAKCb nA7lYq+1RXOz3bai/fNyHfidVjpoeisdQlG377CxGWRgQFQfOGY+8NvxDTvCWvnUNW/2gK2HjL9L7 f/yIyFHcoOgbHi/PW0GGQtxPLd7dAk5mY5AXPPIFgAMOuY+KQKGranRRRl9qNA89CX8q8BMJqwz/2 On2Czz8Q==; Received: by zero.zsh.org with local id 1ranQk-000DA1-OD; Fri, 16 Feb 2024 01:54:22 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f48.google.com ([209.85.218.48]:49278) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ranPv-000CSd-1s; Fri, 16 Feb 2024 01:53:32 +0000 Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a3d159220c7so31838566b.2 for ; Thu, 15 Feb 2024 17:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1708048410; x=1708653210; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=IUDkYBtBRCZ+/pRW3fhQ4rVtLDVtEiwWsB5wpfdMamE=; b=EZL7KwF9xEO92zV0eJynKQEBAprTga7xGaVvQEIiINi8409pU6cDKjqsfSRHn4Od/u xFQXCvSrgyBwAhiSFu3Q0UEcvXTbx3u+IKgw1G6/Xeh3xdfC0ruKPc2/u3TEMPblI3fV Pb753As2MKjx3qNPqjZTlnxeYZv7kWp4AC10ESHM58DblYvvf13i3jiE8+zkN6Tw4PF1 2UqIVvaqTtltsHrObomlGU6S1BNBvHfDpcrKZjCR1b4Mm0l5jDAc/MOjT7ZmJlaY5kEL bNIamHHSxR5fWUyjntKdx0qVMsAxdIZA9GeU4bUcdiGPvt/5y5mFPbM+3z3FNLJ6x3R4 dK6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708048410; x=1708653210; h=content-transfer-encoding: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=IUDkYBtBRCZ+/pRW3fhQ4rVtLDVtEiwWsB5wpfdMamE=; b=WyUIuQ7d20jOx9ISrepynAusbs9cDJJ/NFGjng6IuVVgkTWkoW2MwTYN+zPDmNBKbB i4sDXgAUk71J7RXGbFM2o7rNpJwLx/O1+Ht+xwtNWYMiX0y0q3eReYlcMGwD30WJUxrp W14XjZRrQ84LIQfPHZRKxEEwHOqcRDsdCkwv2RQw81uyHS8oJkFqm5s7sYYCC/Ba3XPs RkPLpCQJ/zhe9KFEcPNWK5U+M+tROcG3RcO2j3CJFUejusV3JR0rVKD45indbS1R06YI vsGx47QHs+eZ8btAp8dbzLrN4ekmMtG1iKgDBiLPHo8FOjzq5k6oVBB8HH7RyjVJ4WVZ XEKQ== X-Gm-Message-State: AOJu0YyNkB7k7vRgKFyBo4od/p+0akm09eQFyfkS6Xpvret6ow9u6/nz UEGcMcG0yMfwWEpPFB6+yvYWej4QqdXKODTHjcrO+A30W+Tr6RuUoFo0V+euGaE0MwGafWlzBKS JBZ6uFmg3by5ojms5m8USMZaR4Suwv8CVEiGdWiRNZBRHOwBcHQ== X-Google-Smtp-Source: AGHT+IHBtY/SvSaDmquVxA/CkbNpuKqDJyBCYg4asq8KLi22P4li5lb6amuBcwnsVURn0rGBGamwKvrRmWW8WJDoiic= X-Received: by 2002:a17:906:759:b0:a3c:a3fa:e452 with SMTP id z25-20020a170906075900b00a3ca3fae452mr2413329ejb.44.1708048410043; Thu, 15 Feb 2024 17:53:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Thu, 15 Feb 2024 17:53:18 -0800 Message-ID: Subject: Re: Counting characters in command output? To: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29681 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: Entering this conversation here because it seems to be the point after which it sort of went off the rails. Go away for a few days and look what I get ... On Tue, Feb 13, 2024 at 10:49=E2=80=AFPM Roman Perepelitsa 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 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. This is a case where original author Paul Falstad chose to stick to the behavior common to other shells. In particular ... In all extent shells at the time, but especially in BSD csh, `command` (backticks) splits its output into words. $(command) and `command` are supposed to be equivalent (except for nesting)= . Therefore $(command) splits its output into words, as happens in every other shell. The only place zsh introduced a distinction from the default splitting behavior of other shells was in parameter expansion. > It's not even common that one wants to split command > output into words. The presumption is that most uses of `command` and $(command) are in the argument list of other commands (for example, that every word of the output is a file name), and that anyone coming to zsh from another shell (which again at the time was the vast majority of zsh users) would be confused if that behavior were not preserved for backticks and therefore also for $(...). If you're using it in an assignment and not to create an argument list, it's entirely consistent with the behavior of scalars and arrays that scalar=3D`command` suppresses splitting (unless the appropriate option is set!) whereas array=3D(`command`) does not, and if you don't want the splitting behavior then you have quoting (or prior assignment) to make your intention clear. If you want command substitution without word splitting, then in whatever the next version ends up being called you have ${ command } to do that for you, and I am very sorry that I wasn't around two days ago to say that. Just for evidence sake: $ csh % ls `echo a b c` ls: cannot access 'a': No such file or directory ls: cannot access 'b': No such file or directory ls: cannot access 'c': No such file or directory