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

Re: trivial question




On 2022-12-04 22:40, Lawrence Velázquez wrote:
It's common enough to forget (or not know) that globs support bracket
expressions.

It's one of those gotchas that baffle the apprentice.  In practice I'd not leave the string unquoted, but  I'm glad to have my curiosity satisfied as to what's going on when it's unquoted. Good example of the 'always quote' maxim in action.  Unless of course you have some specific reason to do otherwise.  I need a better gut understanding of when zsh is going to attempt one of these filename generations, it's naively 'obvious' that 'echo var[2]' is a command to echo a string not look for a filename. With variables of course it's explicit with the dollar sign that one is requesting an expansion, but with files it's up to zsh when and where it wants a string to be a string and when it wants it to be a filename glob.  I myself would have made that explicit too. Then again, the shells started out processing filenames not strings, so it's understandable that things are as they are.  As I said it's a point of curiosity not practical difficulty.

> That was a demonstration of behavior, not a suggestion to disable

And taken as such.

You really need to get out of the habit of enabling/disabling options
that you don't understand just because one of us explains how they
change some behavior or other.  You did the same thing with ERR_EXIT
in users/28432, and it was equally misguided.

The correct remedy here, as usual, is to quote properly, not fiddle
with options.

I experiment with things, that's all.  One can take it on faith that ERR_EXIT is a bad idea, but when one watches it nuke a terminal one knows first hand that it's a bad idea.  It's much easier to remember from experience than by rote.  The nice thing about software is that one can experiment quite wildly without really doing any harm that a restart won't fix.  Obviously there are limitations to that, but still one has considerable latitude. It has always driven my teachers mad, but I learn by breaking things.  I like to Know with a kapital K.  Thanks for the demo code, that's a master class.







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