Substantially reduce wrongly highlighted stuff for Bash #793
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch set contains not only two new features for Bash (namely arithmetic environments and command substitutions), but it uses these features to fix a lot of the annoying stuff about Bash highlighting.
The following simple example should illustrate what I mean:
Here
104
is highlighted as a number,-
as an operator,file
as a function and.
as punctuation. All of these things are wrong, because Bash interprets this as the string"104-file.txt"
.In Bash numbers and arithmetic operations can only exist in arithmetic environments and everything outside of an arithmetic environment is interpreted as a string:
$((5 + 6))
Also keywords and functions can only have certain characters surrounding them namely
/(^|\s|;|\||&)/
. In any other context it is just a string.This patch set fixes all of the above and adds support for command substitution. I also added tests for all of the new features.
The result looks like this: