Skip to content

Commit

Permalink
[ShellScript] Rewrite
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rwols committed Jun 26, 2017
1 parent 303816f commit 660878e
Show file tree
Hide file tree
Showing 12 changed files with 3,460 additions and 568 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plist version="1.0">
<dict>
<key>name</key>
<string>Miscellaneous</string>
<string>Indentation</string>
<key>scope</key>
<string>source.shell</string>
<key>settings</key>
Expand Down
15 changes: 15 additions & 0 deletions ShellScript/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# The update script is located in the tools subdirectory because otherwise
# Sublime will read the file during start-up. No need for that.

all: $(addsuffix .sublime-syntax, $(basename $(wildcard *.yml)))

%.sublime-syntax: %.yml tools/update-commands.py
@printf "$< ==> $@ ... "
@python tools/update-commands.py $< $@
@echo "Done."

test:
@-/usr/bin/env bash test/syntax_test_bash.sh 2>&1 \
| sed -nE "/^test\/syntax_test_bash.sh: line [[:digit:]]+: syntax .*/p"

.PHONY: test
Loading

0 comments on commit 660878e

Please sign in to comment.