New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index expansion operators can be escaped when unquoted #7969
Comments
Nice find, also affects escaped chars:
|
This is mercifully easy to fix - we can just prepend INTERNAL_SEPARATOR like we do for quotes. |
Fixed as 555af37. Thanks for filing! |
@ridiculousfish from the point of view of someone working on a syntax model for fish, this is fantastic, as it hugely simplifies parsing variable expansion. However, I am wondering about a few points related to this change:
|
This is a good theoretical point; in practical terms, I'm not sure anyone would define a non-ASCII variable name. Maybe there's a good reason I'm missing.
Yeah, a The variable-assignment style like There's a practical consideration, which is when constructing the ast we don't want to go through the full set of expansions. For example we recognize |
How quintessentially American a thing to say. As a non English speaker, I have always felt that fish not adhering to the philosophy goes a long way towards filling “friendly” with life … But assuming the intent is not to reduce the valid variable character set to
Well, with invalid command names, actually: fish will complain about a naked
Duly noted, and can’t I relate to that, but I have to point out that, at the same time, fish has the most, ah, expansive expansion rules for keywords of any shell I know, so Anyway, I have managed to correctly handle all the nuances of brace expansion versus literal brace usage and The Case of the Amazing Illegal Opening Bracket in my extension, so changing the parsing for variable expansion is no biggie; I just wanted to be sure the tradeoffs are considered acceptable enough for this to stay in fish. |
This seems rather condescending, and I would prefer not to have that sort of talk here. Note also that I am very much not american, and I agree with @ridiculousfish. You should be naming your variables in ASCII, because that makes it much easier to work with other people and because that removes the considerations of locale from variable names. To be honest
A valid command name is any valid filename. You can call a file "foo=bar" and make it executable. You won't be able to call it via $PATH lookup, because it overlaps with "var=val" syntax, but that's _fish's point. |
No condescension intended, and I sincerely apologise to @ridiculousfish for my flippancy. Believe it or not, what I was actually trying to do is keep my cool, because decades of (almost invariably American) developers bemusedly wondering why anyone would want more than the character set that works for them have worn my nerves paper thin and reduced my willingness to explain why to nil. My choice of reaction obviously backfired, so, again: my apologies. I’m not here to pick a fight.
I’m afraid we will have to disagree on that one: most of my scripts are for my personal use, so portability (if there even is such a thing in the shell universe) is not a consideration, and I haven't used a locale that was not UTF-8 compatible for at least 15 years. Under these conditions, I prefer expressiveness, which means, among other things, using my own language for identifiers. I’m pretty sure I am not the only one, as I have come across localised identifiers in other people’s scripts and snippets; not everybody is fluent in English, and not everybody values portability over expressiveness. In 2021, in the age of ubiquitous Unicode, trying to accommodate this should be a given.
No quibbles with the assessment of
I’ll grant you that pointing this out in my previous comment was needlessly flippant, too, and I am quite willing to apologise a third time, should @ridiculousfish wish for it. As to the matter itself, it boils down to my poor choice of words. What I meant by “invalid” was not that But that is a moot point. As I said: I’m not here to pick a fight; I’ll try to pick my words more carefully next time, instead. |
ok so unicode characters are already valid, and escapes don't seem really necessary here so the current state is fine IMO
yeah, because the equivalent to bash's |
Of course not, but changing the message to something along the lines of “Variable assignments with '=' are only supported when followed by a command. In fish, please use |
Running fish version 3.2.2 (installed via Homebrew) on macOS 11.3 in the stock Terminal.app. I tried fish without third-party customisations by executing
sh -c 'env HOME=$(mktemp -d) fish'
and checked whether it affected the behaviour I am reporting (it did not).While exploring some finer points of the fish syntax (still working on that fish syntax plugin for the Nova editor – believe me, nobody’s sorrier than me to keep on coming up with these issues) I have run into a peculiarity of index range expansion I am pretty sure should be considered a bug. Specifically, the index range expansion operators
[
and]
can be character escaped if the index range expansion is unquoted:The second
echo
statement’s output is both inconsistent with how all other operator-ish characters, paired or not, are treated by fish, and with user expectations as to what escaping should achieve (for instance,echo foo\133bar
will outputfoo[bar
, escaping the unpaired bracket syntax error).Am I correct in assuming this is not intended behaviour? I could model this in my syntax plugin if I must, but this screams “bug” at me …
The text was updated successfully, but these errors were encountered: