-
Notifications
You must be signed in to change notification settings - Fork 4
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
Highlight nested contexts in shellscript #5
Comments
Yeah, this is an issue, there's a few other interpolation issues too. I'll be working on fixing them when writing the grammar completely. It might be awhile before I'm able to rewrite the grammar though |
I wrote a grammar for Sublime Text years ago. I can at least test if not help! I didn't understand about aliases? I imagined it being a recursive context just like quoted expansions and substitutions. |
+1, it's excellent as-is but would love to have nested expansions highlighted i.e. |
@texastoland Thats great to hear, this repo is currently using a beta of a library that makes it's it a lot easier to write grammars, but familiarity with the old grammars will help a lot. Part of the reason I'm not making as many changes is because this repo (along with the similar perl, dockerfile, c, and go syntaxes) is using an out-of-date version of the library. I'm working on finalizing and publishing the library this summer, and then converting this repo to it so that contributions are easier. @texastoland the comment about aliases:
argument context
I'm not certain that an alias is always used as a command |
That doesn't work right? In zsh you could do: # expand when surrounded by whitespace
alias -g anArgument='hello=world'
echo anArgument # > hello=world
echo "anArgument" # > anArgument
anArgument # >
echo $anArgument # >
echo $hello # > world As a general rule highlighting it as a substitution (like |
Yeah, or I'd be surprised if it did, I didn't check it. I'm just saying I'm not sure if it's always used as a command. Maybe it can be an operator, or a value inside of an evaluation, I'd have to find some documentation on it. I'd also need to check edgecases such as how this (below) is handled:
Even small grammar modifications can be a real pain unless you find documentation saying "this format is the only way it is allowed", cause otherwise you have to think of every possible way it could be used instead of just adding support for the most common case. That zsh option is surprising, I didn't think arguments could be expanded like that without a $ I also didn't realize the alias could have the |
That isn't an edge case but the way builtin commands work (those are technically two different things but for simplicity's sake): # define one and print the other
alias thing="echo" hello
# > bash: alias: hello: not found
export thing="echo" hello
declare -p thing hello
# > declare -x thing="echo"
# > bash: declare: hello: not found
Those are parameters. Aliases are used like functions. Aliases are macros. They expand literally in place. In Bash they expand if preceded only by whitespace. In zsh there are flags for expansion between whitespace (global aliases) or as a command depending on file extension (suffix aliases). Even wrapped in quotes they still get For argument's sake in zsh you could do: # no secret yet
alias -g secret='secret is $secret`
echo secret
# > secret is
read-secret # from a file or URL
echo secret
# > secret is 12345 In practice that doesn't happen. Because they're |
Your scripts are really clever but the syntax doesn't highlight expansions nested in double-quoted strings like the original (
"foo ${bar} $(baz)"
). A feature I want even more that's also missing from the original is highlighting inside single-quoted aliases:The text was updated successfully, but these errors were encountered: