when I put for example echo hello and hit ctlr +b it tells me bash: cd: C:\Userserservice: No such file or directory
C:\UsersersaScritorio.sh: command not found
The .sh does not work
ShellScript build system either expects a shebang or the SHELL
environment variable to be set, in order to decide which shell interpreter to run.
The following shebang works on Windows OS.
#!sh
Following shebang however isn’t handled correctly on Windows as /usr/bin/env
doesn’t exist.
#!/usr/bin/env sh
If no shebang is present SHELL=sh
does the trick.
Note 1
Build system doesn’t perform any WSL path translations. So WSL shell wouldn’t find the path to your script.
Note 2
ST’s build system doesn’t provide an interactive shell (or REPL). It’s designed to output compiler messages only.
If you want interactive shell execution, you might be interested in Terminus package.
A Terminus ShellScript.sublime-build might be the most flexible and robust solution (It also works with WSL):
{
"target": "terminus_exec",
"selector": "source.shell",
"shell_cmd": "sh \"./$file_name\"",
"cwd": "${file_path:${folder}}",
// "auto_close": true,
// "focus": true
}