From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18847 invoked from network); 5 Jan 2024 14:42:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Jan 2024 14:42:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1704465776; b=qzvlD8DHGxvZXuoKk7siqqwN8b+Gm9olDaWlqMyr9iuaHEZxMrj014rf441fOvQA6Wf/Z5Lsht pydmf1pj7JEWoHDpe7b7UXfjwHXpeZw0lvkmlUqpw5fYTIAwmcY6XgyitUwzVNhpXaq66rjW+f 0LYv2tkX1TCCmP0TTjyIboQU6RpdAKsirsHGS8H9ngsv6Q000EOA/7SZVtSQShXSn1386FlUuD ZUSEd6+BmyO9s2jOJqpWlolE8dKHsoDAgVnafFftEaY0netkDdx9wOxcl2pNVv8jmfx5LIUy+R MFH3XxQC7oh9/Daq9RRHC6X7ORI69cyHt//J5R8UQJfEaQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f53.google.com) smtp.remote-ip=209.85.167.53; 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=1704465776; bh=no/Ky4MjJxaHM481v5O0ruhBIhJKaMHN97LTfgseOkY=; 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=SQZNgducrJGRmkWvd7ZC+PvH1F+DU+zd9/9gpSXKCsaBR+0W26mX9Jg/CiYnG/v+dXvnOOHllw 6OM2uoqK8YnbTmNI0lnf6MD0guv9F7hTMt5TpNTPo4LTH6T/J7VkLdvIfGl+vLqhfmpVLmS5r8 cCW/lxbYcYlhPd3H+lTDQdQ9fxvKctBLn2dLC0GtK1c+Jx4upcY2OjhBRnVYoQENLF+mCoEh/G jAoE3Liim3VkYqgUd8sevsU6ERukNCo5g/Dc+JcUYxkZbpnq/8e3qsXgLLowE5bORArL21TWSG fYYixm0Cdwv/YMGdX6k3RgMY7vRiCqTB4phycPLJMpzQ+g==; 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=D15VemU4glHAsImRzj/T6qbqKygsC51vpDdYHXdIMsQ=; b=OFKgv1lzwjfx0WwnoeV7v/FVGv cyiuWW2ZujB4v6DiSq2dWpjE60cBHMOzjapnJAyr5PKnm+Uivkgq9yqwXewGqPMCuR1STE8/ijvtr WTS1SMxx638HUhQP/cdjfKYZT+J2R8nj44OIhQwPb9Dca6SqI/y3oNDEXztS0Fg0RXbw0eSQHLQFj VqBnHCe9Y4Qp2Lurw48dmIhIclQ/VTuvD75aGjLFcTriqolNXRJmfnYRduimw8QlsBtXv3tsnCP65 Jto3O+W4KFjE/+mS82FZ75qTRrcWsArUfMwja4CXImcGyGOPsqEeso9BUAS8GWmm3bt7kKZf1rLrn sQItH/Sg==; Received: by zero.zsh.org with local id 1rLlPS-0009xN-4G; Fri, 05 Jan 2024 14:42:54 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f53.google.com) smtp.remote-ip=209.85.167.53; 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-f53.google.com ([209.85.167.53]:60697) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rLlOM-0009EN-2R; Fri, 05 Jan 2024 14:41:47 +0000 Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-50e80d40a41so1976372e87.1 for ; Fri, 05 Jan 2024 06:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704465705; x=1705070505; 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=D15VemU4glHAsImRzj/T6qbqKygsC51vpDdYHXdIMsQ=; b=KvksdtxJkxVVX4xjq8LRVcYwd78UJqUJmCehtqDG/3HnqhQWb+BgurYHvov5AKQTDy 1SXInQfA1yy4/JK5uFrm08FtJ9tZKOOLiGmO4XeJDivsNSRnAf+OPM3ZQtjDJB9fcBsi GfeMMcIzO3og7o8/+2WwHytJvS3EgUj0bdA+XJI1ynb44dGoyf/EbBuITUqckC/GrUNe Pp/AHdokeo3IvcOn2SMQ01qZpFZuKTP/7bFu5n9B9bzbyOV3r7qn4Z3qDKG/W6xkMHxO 26kkN35czyIlBuKa/VbvOYmfZxclGZALJNcGybEJs6czOhxtuHNLbESQEgz0QOnmL1cM GLXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704465705; x=1705070505; 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=D15VemU4glHAsImRzj/T6qbqKygsC51vpDdYHXdIMsQ=; b=qVbMOiGB7xSSli2qGugSWYT3gT24kcXLwDHBCikVVUpBb/p5TWswnjwOMAGpwledfZ lvsmGGIcs/+ttNunp7YWiiOWIQv+gGCsAVPRkhbJdlXC3Fqslb33lDSMiNaLvTUCWauZ H8JMfKq8GX74CH1bpGnTy9PHK3UEWf8lI/2pwIMoKlDoeKXSqkkpQc3RCdRldOkhJTMV fbTjZrKML0ibX5riSrls9QKlQ3GAxwpqn6eSbDHY22ZeKiAiCh+rh3UGaEmL9BtFI4mL pZJY3hoaK84ET7EIzRyZVA623kVdF/zGi6BGfUBUoYCx+ddZBpjTMgUP4se9BmLc1rFv a7Pw== X-Gm-Message-State: AOJu0Yx/jJwPON1ozIiNLNjfX19zJgMtvWb8yzqlAVLDhjZuAsK+2UoL yvlspDKJDb/He5lp1HgCPOp2e2/wVbv+gh/WLC4= X-Google-Smtp-Source: AGHT+IGJxgyzY/sEu2/hcprjd8ZEoN6icI9aksFho1NVALvAjWJl2E+UM5QAfYmoSR1qxhFB8TU10RBk1kacnYUj/wc= X-Received: by 2002:a2e:a68e:0:b0:2cd:20dd:5696 with SMTP id q14-20020a2ea68e000000b002cd20dd5696mr1104407lje.72.1704465704673; Fri, 05 Jan 2024 06:41:44 -0800 (PST) MIME-Version: 1.0 References: <625e7ef5-be1f-4b5d-bb2a-f71634d151cf@eastlink.ca> <3fb34197-be9a-4323-87e0-7052cecf33ea@app.fastmail.com> <3adba5e1-18b6-495e-bcbc-09a554465029@app.fastmail.com> In-Reply-To: From: "Mark J. Reed" Date: Fri, 5 Jan 2024 09:41:32 -0500 Message-ID: Subject: Re: tilde syntax To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="000000000000dbe673060e33d8d9" X-Seq: 29422 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: --000000000000dbe673060e33d8d9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable When you include the value of a variable (parameter) in a command line, the replacement usually happens too late for the resulting value to participate in other sorts of expansion. For example, if you do `echo *`, you'll get a list of the files in the directory. But if you put the `*` into a variable and echo it: $ asterisk=3D'*' $ echo $asterisk * Likewise, if you have a variable with a space in the value, it's not normally subject to word splitting - if you pass it to a command, that command will get a single argument containing a space, not multiple arguments: $ words=3D'one two' $ printf '%s\n' $words one two (It's worth mentioning that in both of the above cases the behavior of zsh is different from the behavior of bash or ksh, in which the parameter value _is_ subject to further expansion.) You can selectively enable further processing with the `~` and `=3D` modifiers. The `~` means that the result of the variable substitution will be subject to wildcard expansion: $ echo $~asterisk Applications Desktop Documents Downloads Library bin etc git lib src tmp While the `=3D` means it will be subject to word-splitting: $ printf '%s\n' $=3Dwords one two On Thu, Jan 4, 2024 at 9:04=E2=80=AFPM Ray Andrews = wrote: > > On 2024-01-04 17:41, Lawrence Vel=C3=A1zquez wrote: > > Another important part occurs earlier in "Parameter Expansion" and > > can admittedly be hard to find: > > Yes. Seems almost inevitable that with such terse syntax normal search > > culture is going to be frustrating. One must master the shell's jargon. > > I wonder if a syntax index could be contemplated, it would look rather > strange: > > $( > > $(( > > $~ > > ${~ > > if[ > > if[[ > > ... every last construction. > > This is why you can use $~foo instead of ${~foo} sometimes. > > I've noticed that but I don't even try to understand it. I am in awe of > the > > geniuses who wrote the parser. The list of ifs, ands, buts and maybes is > > not for a mere mortal to understand. That's what accretion gets you -- > couldn't > > be otherwise. > > That just refers to the result of the parameter expansion being > > subsequently used as something other than a literal value, if the > context calls for it. > > God knows. It's a steep hill to climb if you're not familiar with it. > Anyway I'm > > at least alert to the issue. > > Tx. > > > --=20 Mark J. Reed --000000000000dbe673060e33d8d9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When you include the value of a variable (parameter) in a = command line, the replacement usually happens too late for the resulting va= lue to participate in other sorts of expansion.=C2=A0

= =C2=A0For example, if you do `echo *`, you'll get a list of the files i= n the directory. But if you put the `*` into a variable and echo it:
<= div>
=C2=A0 =C2=A0 $ asterisk=3D'*'
=C2=A0 =C2=A0= $ echo $asterisk
=C2=A0 =C2=A0 *

Likewi= se, if you have a variable with a space in the value, it's not normally= subject to word splitting - if you pass it to a command, that command will= get a single argument containing a space, not multiple arguments:

=C2=A0 =C2=A0 $ words=3D'one two'
=C2=A0= =C2=A0 $ printf '%s\n' $words
=C2=A0 =C2=A0 one two

(It's worth mentioning that in both of the above c= ases the behavior of zsh is different from the behavior of bash or ksh,=C2= =A0in which the=C2=A0parameter value _is_ subject to further expansion.)

You can selectively enable further processing with t= he `~` and `=3D` modifiers.=C2=A0 The `~` means that the result of the vari= able substitution will be subject to wildcard expansion:

=C2=A0 =C2=A0 $ echo $~asterisk
=C2=A0 =C2=A0 Applications= Desktop Documents Downloads Library bin etc git lib src tmp=C2=A0

While the `=3D` means it will be subject to word-splitting= :

=C2=A0 =C2=A0 $ printf '%s\n' $=3Dwords<= /div>
=C2=A0 =C2=A0 one
=C2=A0 =C2=A0 two



=C2=A0 =C2=A0

On Thu, Jan 4,= 2024 at 9:04=E2=80=AFPM Ray Andrews <rayandrews@eastlink.ca> wrote:
=20 =20 =20


On 2024-01-04 17:41, Lawrence Vel=C3=A1zquez wrote:

Another = important part occurs earlier in "Parameter Expansion" and
can admittedly be hard to find:

Yes.=C2=A0 Seems almost inevitable that with such terse syntax norma= l search

culture is going to be frustrating.=C2=A0 One must master the shell&= #39;s jargon.

I wonder if a syntax index could be contemplated, it would look rather strange:

$(

$((

$~

${~

if[

if[[

... every last construction.=C2=A0

This is why you can use $~foo instead of ${~foo} sometimes.
    

I've noticed that but I don't even try to understand it.=C2= =A0 I am in awe of the

geniuses who wrote the parser.=C2=A0 The list of ifs, ands, buts and maybes is

not for a mere mortal to understand.=C2=A0 That's what accretion= gets you -- couldn't

be otherwise.

That jus= t refers to the result of the parameter expansion being
subsequently used as something other than a literal value, if th=
e
context calls for it.

God knows.=C2=A0 It's a steep hill to climb if you're not fa= miliar with it.=C2=A0 Anyway I'm

at least alert to the issue.=C2=A0

Tx.



    


--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--000000000000dbe673060e33d8d9--