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

shell highlighting broken if no space follows <<< #626

Closed
mvdan opened this issue Sep 21, 2016 · 8 comments · Fixed by #1057
Closed

shell highlighting broken if no space follows <<< #626

mvdan opened this issue Sep 21, 2016 · 8 comments · Fixed by #1057
Labels
T: bug A bug in an existing language feature

Comments

@mvdan
Copy link

mvdan commented Sep 21, 2016

See rmarquis/pacaur#557 (comment) and rmarquis/pacaur#557 (comment).

@wbond wbond added the T: bug A bug in an existing language feature label Sep 21, 2016
@oriSomething
Copy link

I just get this error no matter what
screen shot 2016-09-22 at 08 16 33

@t-bltg
Copy link
Contributor

t-bltg commented Sep 22, 2016

Build 3124 breaks the shell syntax (25000 sanity limit) for me as well on Ubuntu 16.04

@jfcherng
Copy link
Collaborator

jfcherng commented Sep 22, 2016

Interesting... there is no real change between 3124 and 3114 for shellscript.

You may temporary switch to use https://packagecontrol.io/packages/ShellScriptImproved before there is a official shellscript re-write.

@wbond
Copy link
Member

wbond commented Sep 22, 2016

If you are hitting the recursion error it means you have a third party syntax installed that is creating an include loop. This is very likely an HTML syntax, but may be something like JavaScript.

@FichteFoll
Copy link
Collaborator

Or some markdown flavor.

@t-bltg
Copy link
Contributor

t-bltg commented Sep 23, 2016

@jfcherng thanks, it's a fix for now ...

@wbond
Copy link
Member

wbond commented Sep 23, 2016

What is almost certainly happening is that Shell Script allows embedded heredocs of the syntaxes Markdown, HTML, Python, Ruby, AppleScript and Textile. One of those syntaxes on your machine must be from a third-party package, and must have a scope that includes Shell Script directly (for embedding), or includes it via another include.


The one possible way to stem the tide of such recursion errors is for Sublime Text to add functionality that allows omitting a context when embedded. Then, we'd add an embed: directive like include: that would just skip contexts marked with skip_embedding: true. So, you could allow Shell Script to embed PHP, but it would include a version of PHP that does not highlight heredocs with embedded languages. This could also potentially make with_prototype more useful, since that can easily lead to include recursion.

This would almost certainly work fine in practice, since it would be kind of crazy for someone to embed PHP with a heredoc of a Shell Script inside of a Shell Script heredoc. And if they did, it would seem perfectly fine to not syntax highlight the innermost Shell Script code.

rwols added a commit to rwols/Packages that referenced this issue Jun 26, 2017
Issue links
-----------
Intends to close sublimehq#434
Fixes sublimehq#626
Fixes sublimehq#190
Fixes sublimehq#46

Goodies
-------

* Proper context sensitive command invocations
* Variable expansion as from ShellScriptImproved
* Backtick handling as from ShellScriptImproved
* No with_prototype contexts
* Generic options handling
* Builtin-commands know their valid options
* Renamed Shell-Unix-Generic to bash, as it's really just bash (and dash)

About 1300 syntax tests, tested out in the wild with various bash scripts.

Deficiencies
------------

The heredocs handling is still not perfect, but it gets the job done if you
don't have a function definition, inline if-block or compound command on
the same line as the start of the heredoc token.

* It's easy to bring back the embedded language highlighting for particular
  heredoc tokens, but this is omitted for now.
* It's easy to embed the regex language for regex matching in if-blocks at
  this point.

Acknowledgements
----------------

* @jfcherng for starting ShellScriptImproved and the huge amount of syntax
  tests,
* @okdana for creating syntax tests,
* @FichteFoll for pointing me to the Ruby syntax for heredoc handling,
* @KingKeith, @wbond for their suggestions about scope names.
rwols added a commit to rwols/Packages that referenced this issue Jun 26, 2017
Issue links
-----------
Intends to close sublimehq#434
Fixes sublimehq#626
Fixes sublimehq#190
Fixes sublimehq#46

Goodies
-------

* Proper context sensitive command invocations
* Variable expansion as from ShellScriptImproved
* Backtick handling as from ShellScriptImproved
* No with_prototype contexts
* Generic options handling
* Builtin-commands know their valid options
* Renamed Shell-Unix-Generic to bash, as it's really just bash (and dash)

About 1300 syntax tests, tested out in the wild with various bash scripts.

Deficiencies
------------

The heredocs handling is still not perfect, but it gets the job done if you
don't have a function definition, inline if-block or compound command on
the same line as the start of the heredoc token.

* It's easy to bring back the embedded language highlighting for particular
  heredoc tokens, but this is omitted for now.
* It's easy to embed the regex language for regex matching in if-blocks at
  this point.

Acknowledgements
----------------

* @jfcherng for starting ShellScriptImproved and the huge amount of syntax
  tests,
* @okdana for creating syntax tests,
* @FichteFoll for pointing me to the Ruby syntax for heredoc handling,
* @keith-hall, @wbond for their suggestions about scope names.
rwols added a commit to rwols/Packages that referenced this issue Jun 26, 2017
Issue links
-----------
Intends to close sublimehq#434
Fixes sublimehq#626
Fixes sublimehq#190
Fixes sublimehq#46

Goodies
-------

* Proper context sensitive command invocations
* Variable expansion as from ShellScriptImproved
* Backtick handling as from ShellScriptImproved
* No with_prototype contexts
* Generic options handling
* Builtin-commands know their valid options
* Renamed Shell-Unix-Generic to bash, as it's really just bash (and dash)

About 1300 syntax tests, tested out in the wild with various bash scripts.

Deficiencies
------------

The heredocs handling is still not perfect, but it gets the job done if you
don't have a function definition, inline if-block or compound command on
the same line as the start of the heredoc token.

* It's easy to bring back the embedded language highlighting for particular
  heredoc tokens, but this is omitted for now.
* It's easy to embed the regex language for regex matching in if-blocks at
  this point.

Acknowledgements
----------------

* @jfcherng for starting ShellScriptImproved and the huge amount of syntax
  tests,
* @okdana for creating syntax tests,
* @FichteFoll for pointing me to the Ruby syntax for heredoc handling,
* @keith-hall, @wbond for their suggestions about scope names.
@rwols
Copy link
Contributor

rwols commented Jul 16, 2017

The one possible way to stem the tide of such recursion errors is for Sublime Text to add functionality that allows omitting a context when embedded. Then, we'd add an embed: directive like include: that would just skip contexts marked with skip_embedding: true. So, you could allow Shell Script to embed PHP, but it would include a version of PHP that does not highlight heredocs with embedded languages. This could also potentially make with_prototype more useful, since that can easily lead to include recursion.

Related: sublimehq/sublime_text#1534

deathaxe pushed a commit to deathaxe/sublime-packages that referenced this issue Jun 9, 2019
Issue links
-----------
Intends to close sublimehq#434
Fixes sublimehq#626
Fixes sublimehq#190
Fixes sublimehq#46

Goodies
-------

* Proper context sensitive command invocations
* Variable expansion as from ShellScriptImproved
* Backtick handling as from ShellScriptImproved
* No with_prototype contexts
* Generic options handling
* Builtin-commands know their valid options
* Renamed Shell-Unix-Generic to bash, as it's really just bash (and dash)

About 1300 syntax tests, tested out in the wild with various bash scripts.

Deficiencies
------------

The heredocs handling is still not perfect, but it gets the job done if you
don't have a function definition, inline if-block or compound command on
the same line as the start of the heredoc token.

* It's easy to bring back the embedded language highlighting for particular
  heredoc tokens, but this is omitted for now.
* It's easy to embed the regex language for regex matching in if-blocks at
  this point.

Acknowledgements
----------------

* @jfcherng for starting ShellScriptImproved and the huge amount of syntax
  tests,
* @okdana for creating syntax tests,
* @FichteFoll for pointing me to the Ruby syntax for heredoc handling,
* @keith-hall, @wbond for their suggestions about scope names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug A bug in an existing language feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants