Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: trivial question



On Mon, Dec 5, 2022, at 9:11 AM, Ray Andrews wrote:
> I need a better gut understanding of when zsh 
> is going to attempt one of these filename generations

A decent starting point is to assume that unquoted punctuation is
special until you verify otherwise (assuming you don't actually
want the special behavior).  Even then you might as well quote it
to avoid confusing your future self.

> it's naively 
> 'obvious' that 'echo var[2]' is a command to echo a string not look for 
> a filename.

Presumably you've internalized that "*" is a globbing character,
so you wouldn't be confused if this printed a bunch of filenames:

    echo *.txt

Once you know that "[" is also a globbing character, it should cease
to be confusing.  That said, remembering all the globbing characters
can be a challenge, especially the ones you don't use regularly.

-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author