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_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 8472B2381D for ; Sun, 14 Apr 2024 17:12:42 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1713107562; b=GL6FxmWWzq06DwCT5tAQFB/lugKa5wW52KKAWJ4mDHtNZNzOVgHPXqy8qWrUKtwLBPotMGLeDw r8fLgtHDo/Psw6CmhO3JoKkftffglTcs/XwvaR6yTfhJB+TSgBXHWA/xWZEdvmQtRq7EuBT33d RzCcJGJICgZiFGBvKa7vR6i3IY+WAfOdWF1lWe/m3nSoFgPTRTuCFHBxxmpa2lGt80We9EMhiH 4hmTipAAwmQhxQKFPhxFfSnOfYWCgHb6hqWGvDmRbEc+1eHzIr0OUhfeGsVUnDdNE19Gaw94Vz 8V8Kv+d4sLz7abDd6MU5uUTBOwNoZkx0Nxq6tze4f1EkPw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f54.google.com) smtp.remote-ip=209.85.167.54; 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=1713107562; bh=iQ99oGo5zkEm0KJHB3k+KCgDCC10uUe/+RPrLoOXvBE=; 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=G0N9w2OUpsbtE6xVDIA5TlvlZCJ0LKJW0uRrjn5dMCIVXxzco6eVnOWynf6Wm+Ixof34vg5K+2 eiybJR4SSKuSY5WMRGwwpzLuM3zpNpKvhgqY2w8P9Gsa1XNkS21V8pcyhGBpyl9K6YvLn5J0vn C6ZC/yfAfy0kkF4HuyMxlXjhKLMPDWz31DF/W2qqAiPywuGnOacgdBPGI5RL7X+Fj2FBazfBJ6 PTfLdms81yig+mfZTfY+RtPlY2/bXBVWygm4WTBAXp299zdXq3NaOXgbeI1b5rCp7vtHnhncLy 9zwVJ+ol3NWc1GwTmBIPRqniJu8Eazb5L+j6TvnKYZ8T9g==; 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=f0nNh+JzeytGqJ8XSfZwJHcvevhnqNEiKhODm0paz0o=; b=Qa37gxv6et75xfCYIv3BjWi+rC jexS1RfISefqqnlHZ96664+lCAh49rr3fzeGMnvhmi0Ee+mh0wnGxVW26aKdnUD0YeBr9Z7WmWP7A 0O6M2TcruVm/TcmeOPK3ECqc0cdVhI3npWmrJIbBMY9Uxq2mFYi68WQPr4wQ0gkLxXDNGohxMrpeQ zpcFg8bagf+g/goRRIgW+D1Ds+6ii8TywYNnPVJ7+uw1XW16Mo+8RkCbYTk9mEldaGvCze8M4hk9t Un+uXt9+kxJZYFuX5l3+Tuf+2WH7htlmc+8VH8JrA0GhlpFuQIXOP1iqmLWBFHS4B24Cwz3Ed096D WclHRygA==; Received: by zero.zsh.org with local id 1rw1X8-000NB2-6d; Sun, 14 Apr 2024 15:12:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f54.google.com) smtp.remote-ip=209.85.167.54; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f54.google.com ([209.85.167.54]:42110) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rw1WB-000MRa-EY; Sun, 14 Apr 2024 15:11:45 +0000 Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-518a3e0d2e4so1032611e87.0 for ; Sun, 14 Apr 2024 08:11:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713107502; x=1713712302; 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=f0nNh+JzeytGqJ8XSfZwJHcvevhnqNEiKhODm0paz0o=; b=mTIeixxcWFKmWofuAvsPdVtKp/SBbwGlwL2bOaZAi8r/J6TVoJ5qFWB8W7Jhjf4M41 EGfaVI2+dfkutTIbV8M87XSC4LxH2oyCMldRadNErE7tGMOrqLkLhj1lE/sZi89OJG0u 9yjgex0sISULOp8A/be1X4NXwWj923bf16yrI0X9eMMLUz9iHISX1/zAZB+K//q7u5UN /PrdM10wSVePJ4gkmb0c5iekr0vwQXzgI2lNRLThwsTOrcTVuyeDfNn4yZWPlk/4dhnr zxIRNbwjk9hYK+9MaLXRaY7tyv+CeLAWzE4YthEfruOlu3qwLnQM15N2WoQ+SdNXalB1 eAxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713107502; x=1713712302; 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=f0nNh+JzeytGqJ8XSfZwJHcvevhnqNEiKhODm0paz0o=; b=wEXOH3J/eBv6zzL+A/E6IUd1OvZcgzIpuKJuSoFhsjUOawHGsSPL26XKYfuFPYd8XN x5sZ18sFvVvmREAygsPXFQAhpYJYUCzkiykGJ+Qh6jHTvjSiWJE6gppa2PGFWO3PKO4w FtWcAPG0P+8YNgtymUdPI0I6McBpcxY3AxXZQrHHwpgqehAftmM5nTIAOpG68ABibYs7 zIUD4XY4v/77ChRRyO+IVuuE3QP0ppJuKimmPnr/1sD7wYeEcoVzbd4qFGM6FcbDPLFL hyjZhaEIvHEfwl5w5Ixl64w40n9BAhZRNC5QYRmuw7pIL7HU0LzmX2L7crW6CwuOia+g 6qSg== X-Gm-Message-State: AOJu0YwkbOeRH44rHoZI5vx1edGYJDX6Tr2MJbyvvC1TFV69mBzxfd2q B9y8aCdPABL/jVL4gwgGOKL4nNvZwzVF+3NGtzO6ZsHVZuKHvnh7EVAuGHy8MN6Np8+BNaaO+pU 2hdIU+ST/n0fYKsJEIVyr9XU6J0+OETXqKQw= X-Google-Smtp-Source: AGHT+IElT4GdcMNm5Tb7eh+ImRW0CN8FiZsyTtfW9on8Jo+H93pA4YC+R4gnBJVHaTQ+geCgNlW9sP2evpF1bHlTFoM= X-Received: by 2002:ac2:4c17:0:b0:516:ce34:e4fc with SMTP id t23-20020ac24c17000000b00516ce34e4fcmr3113146lfq.31.1713107502480; Sun, 14 Apr 2024 08:11:42 -0700 (PDT) MIME-Version: 1.0 References: <97793422-1543-4ba6-b52b-ff93eba03ab1@eastlink.ca> <0a0b9ec3-4661-4386-9fbf-b3152a46001e@eastlink.ca> <9416dc0a-3e41-4229-a9e1-239411ab3c17@eastlink.ca> <4a1e027c-a9d8-4306-bf3b-e1282914644c@app.fastmail.com> <4e9aa98c-9b5d-4e22-b7fc-8c50a9af9ada@eastlink.ca> <52e2a591-b083-4e50-8fed-0685d42088df@eastlink.ca> <9e41a059-c051-4124-8296-48ccd97f793c@eastlink.ca> In-Reply-To: <9e41a059-c051-4124-8296-48ccd97f793c@eastlink.ca> From: "Mark J. Reed" Date: Sun, 14 Apr 2024 11:11:30 -0400 Message-ID: Subject: Re: triviality regarding $# counts To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="00000000000025c7ad06160feca8" X-Seq: 29826 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: --00000000000025c7ad06160feca8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable As I said about *echo* way back in my first response: the *print* command is what is turning the backslash-n sequences into newlines. If you use *-r*= to turn off that behavior, you can see the strings unmangled: % print -r $ggg abc\n \n def\n \n ghi\n The -r is telling print not to do something it normally does. The result is the raw string (which I think is what *-r* stands for). To restate: if your goal is to print out a newline, you have options. If you do this: print $'\n' Then you are creating in the shell's memory a string containing a literal newline character (one byte with value 10), which the shell then passes to *print*, which just echoes it verbatim, doing no translation on it whatsoever. Job done. The translation from \n to newline was done by the shell before *print* ever ran. If you instead do this: print '\n' Then the string you create and pass to *print* has no newline in it. It is not one byte of value 10, but two bytes, one with value 92 (backslash) and the second with value 110 (lowercase *n*). The code implementing the *print* command recognizes this sequence as code for "print a newline", so it does. But that's the command doing that. The string itself has no newline in it. Mark J. Reed On Sun, Apr 14, 2024 at 10:53 Ray Andrews wrote: > > > On 2024-04-14 07:15, Roman Perepelitsa wrote: > > On Sun, Apr 14, 2024 at 4:06=E2=80=AFPM Ray Andrews > wrote: > >> % ggg=3D( 'abc\n' '\n' 'def\n' '\n' 'ghi\n' ) > > There are no newlines in there. > % ggg=3D( ' abc\n' '\n' 'def\n' '\n' 'ghi\n' ) > > % print $ggg > abc > > def > > ghi > > > % typeset -p ggg > typeset -a ggg=3D( ' abc\n' '\n' 'def\n' '\n' 'ghi\n' ) > > > > --00000000000025c7ad06160feca8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
As I said about echo way back in my first resp= onse: the print=C2=A0command is what is turning the backslash-n sequ= ences into newlines. If you use -r=C2=A0to turn off that behavior, y= ou can see the strings unmangled:

%= =C2=A0print -r $ggg=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0

=C2=A0abc\n \n def\n \n ghi\n<= /span>


=

The -r is telling print not to do something it norm= ally does. The result is the raw string (which I think is what -r=C2= =A0stands for).

To restate: if your goal is to prin= t out a newline, you have options. If you do this:

print $'\n'=C2=A0

Then= you are creating in the shell's memory a string containing a literal n= ewline character (one byte with value 10), which the shell then passes=C2= =A0to print, which just echoes it verbatim, doing no translation on = it whatsoever.=C2=A0 Job done. The translation from \n to newline was done = by the shell before print=C2=A0ever ran.

If = you instead do this:

=
print '\n'

Then the string you cr= eate and pass to print=C2=A0has no newline in it. It is not one byte= of value 10, but two bytes, one with value 92 (backslash) and the second w= ith value 110 (lowercase n).=C2=A0 The code implementing the=C2=A0print=C2=A0command recognizes this sequence as code for "print a = newline", so it does. But that's the command doing that. The strin= g itself has no newline in it.=C2=A0



=
Mark J. Reed <markjreed@gmail.com>
=


On Sun, Apr 14, 2024 at 1= 0:53 Ray Andrews <rayandrews@eastlink.ca> wrote:


On 2024-04-14 07:15, Roman Perepelitsa wrote:
> On Sun, Apr 14, 2024 at 4:06=E2=80=AFPM Ray Andrews <rayandrews@eastlink.ca>= ; wrote:
>> % ggg=3D( 'abc\n' '\n' 'def\n' '\n'= ; 'ghi\n' )
> There are no newlines in there.
% ggg=3D( ' abc\n' '\n' 'def\n' '\n' 'g= hi\n' )

% print $ggg
=C2=A0=C2=A0abc

=C2=A0=C2=A0def

=C2=A0=C2=A0ghi


% typeset -p ggg
typeset -a ggg=3D( ' abc\n' '\n' 'def\n' '\n= 9; 'ghi\n' )



--00000000000025c7ad06160feca8--