zsh-users
 help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: uninvited members of associative array
Date: Fri, 16 Dec 2022 20:25:54 +0000	[thread overview]
Message-ID: <f91883d5-ae96-40eb-a83e-1c32d1f2d8a7@app.fastmail.com> (raw)
In-Reply-To: <Y5zBPG+WSTC/mG9n@localhost>

Dominik Vogt wrote on Fri, 16 Dec 2022 19:04 +00:00:
> On Fri, Dec 16, 2022 at 10:21:28AM -0800, Ray Andrews wrote:
>> Yeah.  I'm sure many of my own travails have been due to that kind of ...
>> well, one could say 'shortcutting', but more often it's simply not
>> understanding the vulnerability of unquoted vars. As a few weeks ago, when
>> what was it ... something unquoted with '[]' in it tried to expand to a list
>> of files.  It's far to late to do anything about it design wise, but if it
>> were up to me the shells would have evolved from their warm little ponds
>> with a 'positive option' mentality vs. the 'negative option' that we
>> currently have.  Basically: If I want something I'll ask for it. If I want a
>> var to expand to filenames I'll request that.

You mean that you wrote foo[bar] and didn't realize that was
a globbing syntax too?  zsh can't disable features because you don't
know them.  I suppose you could go ahead and disable all glob characters
other than those you know, or perhaps you could propose a GLOB_VERIFY
option akin to HIST_VERIFY.

>> If I want empty elements
>> removed from an array I'll say so.   As it is zsh loves to do helpful things
>> whether you want them or not  and you have to ask for the exemption.  Mostly
>> by quoting but the world would have been simpler if it had been the other
>> way. Dunno, maybe not.  When one is dealing on the command line, probably
>> file-centrism makes sense.  But when it's variable contents the opposite is
>> true.  Anyway the thing is to learn the lesson early: quote.
>
> I think you have a grave misconception of shells.  Shells are
> basically command line interpreters with some text processing.  A
> command line is a string with shell specific instructions to
> generate a final list of constant strings.  These are then
> interpreted as a command name and its arguments.  There's no
> conception of symbolic values; all input is just text.  Shells are
> are not "programming languages".  The shell does not know about
> file names on the command line, it just expands strings to
> filenames if they contain globbing patterns.

Yeah, the syntax rules are well-defined, but they aren't always
intuitive.  I don't know of any other language that does null elision on
arrays, for instance: in most languages, if you loop over an array that
contains ('foo' '' 'bar'), you get three iterations.  In zsh you get two
unless you specifically request three.

In other words, the "default" syntax (the one with the fewest tokens)
doesn't give the should-be-default behaviour.


  parent reply	other threads:[~2022-12-16 20:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15 23:48 Ray Andrews
2022-12-16  0:05 ` Lawrence Velázquez
2022-12-16  0:48   ` Ray Andrews
2022-12-16  1:29     ` Lawrence Velázquez
2022-12-16  2:09     ` Dominik Vogt
2022-12-16  2:56       ` Ray Andrews
2022-12-16  3:21         ` Lawrence Velázquez
2022-12-16  4:16           ` Ray Andrews
2022-12-16 10:05             ` Dominik Vogt
2022-12-16 14:13               ` Ray Andrews
2022-12-16 15:19                 ` Dominik Vogt
2022-12-16 19:14                   ` Ray Andrews
2022-12-16 16:30                 ` Daniel Shahaf
2022-12-16 18:21                   ` Ray Andrews
2022-12-16 19:04                     ` Dominik Vogt
2022-12-16 20:10                       ` Ray Andrews
2022-12-16 21:15                         ` Dominik Vogt
2022-12-16 21:33                           ` Bart Schaefer
2022-12-16 21:59                             ` Dominik Vogt
2022-12-16 22:15                               ` Bart Schaefer
2022-12-16 23:33                                 ` Ray Andrews
2022-12-17 12:47                                   ` Pier Paolo Grassi
2022-12-17 17:32                                     ` Ray Andrews
2022-12-17 18:10                                 ` Ray Andrews
2022-12-17 18:19                                   ` Roman Perepelitsa
2022-12-17 20:31                                     ` Ray Andrews
2022-12-17 20:49                                       ` Bart Schaefer
2022-12-17 21:07                                       ` Lawrence Velázquez
2022-12-17 21:52                                         ` Ray Andrews
2022-12-17 22:10                                           ` Bart Schaefer
2022-12-17 23:41                                             ` Daniel Shahaf
2022-12-18  0:15                                             ` Ray Andrews
2022-12-18  0:25                                               ` Daniel Shahaf
2022-12-18  2:13                                                 ` Ray Andrews
2022-12-18 20:12                                                   ` Daniel Shahaf
2022-12-18 20:26                                                     ` Bart Schaefer
2022-12-18 20:41                                                       ` Ray Andrews
2022-12-18  3:44                                               ` Lawrence Velázquez
2022-12-17 23:25                                         ` Daniel Shahaf
2022-12-16 21:33                           ` Ray Andrews
2022-12-16 20:25                       ` Daniel Shahaf [this message]
2022-12-16 21:43                         ` Dominik Vogt
2022-12-16  3:20 ` Bart Schaefer
2022-12-16  4:15   ` Ray Andrews
2022-12-16  8:12 ` Roman Perepelitsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f91883d5-ae96-40eb-a83e-1c32d1f2d8a7@app.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).