-
Notifications
You must be signed in to change notification settings - Fork 591
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
[ShellScript] Add ZSH #4024
Merged
Merged
[ShellScript] Add ZSH #4024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit... 1. adds missing -f and -p options for wait built-in 2. adds dedicated tests for job built-in commands 3. refactors job variable tests by replacing `fg` command by `:` dummy to align them with majority of other variable tests
This commit fixes support for brace expansions according to bash syntax specs. Former `number-range` was just a special case for what brace expansions can do.
This commit ... 1. applies structural changes, required for ZSH. 2. fixes various parameter expansion bugs related with special parameters e.g. `${$}`, `${?}`, ... 3. fixes advanced tilde expansions such as `~name/` or `~+/` In general it means to introduce contexts and rules to scope expansions more precisely and detailed.
This commit removes quote-removal from function and alias identifiers as it is not supported by Bash. Function identifiers must be unquoted literals.
This commit makes it easier to extend contexts in inherited syntax definitions.
This commit scopes function bodies with a commonly used meta scope in favor of Bash's "compound" command as preparation for other shells, which follow closer to other programming languages. It removes redirections from context stack as those are handled globally.
This commit applies required changes to support ZSH case statements, which may use curly braced code blocks as in C, which didn't work well with previous meta scope structure.
This commit... 1. refactors how word boundaries and quotes are treated. Motivation: A reliably distinction between tilde-expansions and logic operators is required in ZSH pattern matching to support the following: cmd ~/path/*~*.com ^ operator ^ tilde expansion 2. assigns `string` scope to all suitable strings and patterns to enable color schemes to more clearly distinguish them from variables. Note: Aligns Bash with "Batch File" syntax. 3. refactors command argument list termination Replace clunky and messy "boilerplate" contexts with proper "cmd-args-end". Note: Aligns Bash with "Batch File" syntax.
Everything between options and end of command is a string, regardless quotation. This commit therefore introduces special contexts for `echo` builtin.
This commit... 1. fixes [ command termination behavior - terminate at \n ; && or || as normal `test` builtin 2. prefers scoping < > as comparison operator as it is more likely to be valid than redirections. Note: May need further refinements 3. highlight unquoted ; illegal in [[ ... ]] compound test expressions 4. fixes word boundaries of strings withing test expressions
This commit scopes all pre-defined built-in variables and distinguishes them from special variables such as `$0` or `$*`. Fixes an issue with `$_` vs. `$$_` highlighting. see: https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables
Move up expressions and operators contexts.
This commit moves literals, strings and pattern matching contexts up, right after heredocs.
This commit... 1. enables support for correctly scoping literal and arithmetic assignment values in `declare` commands and its friends. 2. fixes unsupported nested `(...)` in value sequences. The following is illegal `var=(foo (bar baz))`. 3. distinguishes option assignment values and variable assignment values. Only the latter supports value sequences wrapped in parens.
This commit... 1. drops leading `\b` from `numbers`'s patterns as proper global word boundary checks are available. 2. treat numbers as words, consuming everything until word boundary and scope it illegal if not valid part of a number.
1. `comments` is not required 2. `line-continuations` is already provided by `eol-pop`
Only redirections are allowed after compound commands, which is already satisfied/handled via global statements context.
1. always clear parent scope 2. scope username `constant.other`
Use already existing `invalid.illegal.unexpected-token.shell`
This commit assigns `meta.string.glob` scope to strings, which support filename expansions.
Variable subscriptions undergo arithmetic expansion.
deathaxe
force-pushed
the
pr/shellscript/zsh
branch
from
September 22, 2024 08:34
edddabf
to
78bf083
Compare
deathaxe
force-pushed
the
pr/shellscript/zsh
branch
from
September 22, 2024 08:37
78bf083
to
87b2a78
Compare
michaelblyons
previously approved these changes
Sep 22, 2024
deathaxe
added a commit
to deathaxe/Containerfile
that referenced
this pull request
Sep 22, 2024
This commit fixes compatibility with some breaking changes introduced by sublimehq/Packages#4024. CAUTION: It is not forward or backward compatible!
This was referenced Sep 22, 2024
michaelblyons
previously approved these changes
Oct 12, 2024
Okay, so there's a test failure from the Groovy changes, but otherwise still 👌🏼 from me. |
michaelblyons
previously approved these changes
Oct 13, 2024
This commit reorganizes statement contexts for built-in commands to be augment-able by local function definitions, while keeping higher priority of reserved words. Reserved words, like `if`, `case`, ... can not be used as identifier for local function definitions, but all other built-in commands can be. As a result `def-anonymous` and `def-function` contexts can be merged. `cmd-coproc` is re-defined as kind of function definition under `def-coproc`. The token `time` is moved to `cmd-control` context and scoped `keyword.control` as it is a reserved word.
Thank's for your feedback. It turned out to be a long-living design/priority issue, which Bash on master suffers from as well. Fixed. |
keith-hall
approved these changes
Oct 23, 2024
michaelblyons
approved these changes
Oct 23, 2024
Great! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1358
Fixes #2635
Resolves #3826
Fixes #4033
This PR refactors Bash as foundation for adding Zsh.
Used syntax specifications:
Syntax follows officiel specifications as close as possible
to reliably support most language features.
Bash highlights
Various scopes of keywords, punctuation, etc. have been modified
to follow latest scope naming best practices.
Those may cause syntax tests of 3rd-party packages to fail.
Syntax highlighting itself should however still work.
Zsh highlights
Benchmarks
Parsing performance is evaluated using syntax test files from current release
and various other real world scripts.
This PR does not affect parsing performance.