Skip to content

Commit 895d6de

Browse files
spikespazkaste
authored andcommitted
Add Windows support using WSL (#9)
1 parent 47b8ba2 commit 895d6de

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ Before using this plugin, you must ensure that `shellcheck` is installed on your
1515
To install `shellcheck`, follow the instructions on [the shellcheck GitHub repository](https://github.com/koalaman/shellcheck).
1616

1717
`shellcheck` can be installed with ``apt-get`` on Debian sid, ``brew`` on Mac OS X, or compiled from its Haskell sources (manually, or through `cabal`).
18-
There is no Windows installer.
1918

20-
In order for `shellcheck` to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. The docs cover [troubleshooting PATH configuration](http://sublimelinter.readthedocs.io/en/latest/troubleshooting.html#finding-a-linter-executable).
19+
On Windows, the Linux Subsystem must be enabled. See [Microsoft's guide](https://docs.microsoft.com/en-us/windows/wsl/install-win10), then run `wsl sudo apt install shellcheck` to install Shellcheck (if you installed ubuntu).
20+
21+
On native Linux systems, in order for `shellcheck` to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. The docs cover [troubleshooting PATH configuration](http://sublimelinter.readthedocs.io/en/latest/troubleshooting.html#finding-a-linter-executable).
2122

2223
## Settings
2324
- SublimeLinter settings: http://sublimelinter.readthedocs.org/en/latest/settings.html

linter.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,22 @@
2121
"""
2222

2323
from SublimeLinter.lint import Linter
24+
from shutil import which
25+
import sublime
2426

2527

2628
class Shellcheck(Linter):
2729
"""Provides an interface to shellcheck."""
2830

2931
syntax = ('shell-unix-generic', 'bash')
3032
cmd = 'shellcheck --format gcc -'
33+
34+
if sublime.platform() == 'windows':
35+
if which('wsl'):
36+
cmd = 'wsl ' + cmd
37+
else:
38+
raise OSError('Either the current system is not 64-bit, or WSL is not enabled. See the README file.')
39+
3140
regex = (
3241
r'^.+?:(?P<line>\d+):(?P<col>\d+): '
3342
r'(?:(?P<error>error)|(?P<warning>(warning|note))): '

0 commit comments

Comments
 (0)