Skip to content
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

Incorrect syntax highlighting of shell aliases #87

Open
PavelSafronov opened this issue May 7, 2024 · 1 comment
Open

Incorrect syntax highlighting of shell aliases #87

PavelSafronov opened this issue May 7, 2024 · 1 comment

Comments

@PavelSafronov
Copy link

The code with a problem is:

alias ll='ls -alF'
alias ..='cd ..'

It looks like:

Screenshot 2024-05-07 at 3 45 52 PM

It should look like:

The two lines should have the same highlighting: alias should blue in both cases.

@shtev21
Copy link

shtev21 commented Oct 9, 2024

From what I can gather, it occurs when the alias has a period (as well as a few other characters).

All aliases that contain a . will have incorrect highlighting for the remainder of that alias' scope only and the problem doesn't 'bleed' to other aliases.

Examples

Syntax highlighting fails for l. alias but resumes for the following ```rm`` alias:

image

Syntax highlighting fails for cd.. but NOT cd-

image

Is it the responsibility of a syntax highlighter to adhere to the specifications of a language even when that allows for valid code that has unexpected functionality?

Regarding valid aliases, the Bash man pages say:

Aliases 🔗

The characters /, $, `, and = and any of the shell metacharacters or quoting characters listed above may not appear in an alias name.

Metacharacter 🔗

A character that, when unquoted, separates words. A metacharacter is a space, tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’, ‘(’, ‘)’, ‘<’, or ‘>’.

Which seems to allow foo. as an acceptable alias, which seems reasonable. However it also allows bar[ which in my testing, causes the alias not to function as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants