Sublime Forum

Bash Script as sublime-build Command

#1

The deployment process I use is a little complicated, so I have build a .sh script to handle it all for me. It’s all set up to just take the file path and it builds and deploys everything. The .sh runs perfectly fine starting #! /bin/bash perfectly fine if I execute it from the terminal. It does not work when I execute it from Sublime Text 2.

My build file looks like this:

{ "cmd": "./sublimeAntDeploy.sh", "$file"], "shell": true, "working_dir": "${project_path:${folder}}" }

My .sh script lies in the project directory and appears to be found just fine because the errors I get are:

./sublimeAntDeploy.sh: line 4: dirname: command not found ./sublimeAntDeploy.sh: line 6: basename: command not found ./sublimeAntDeploy.sh: line 7: awk: command not found ./sublimeAntDeploy.sh: line 9: sed: command not found ./sublimeAntDeploy.sh: line 10: sed: command not found ./sublimeAntDeploy.sh: line 16: rm: command not found ./sublimeAntDeploy.sh: line 18: mkdir: command not found

I’m not sure what kind of shell it’s using when I tell it to execute my .sh with shell, but I figured it would be using bash. Does Sublime Text 2 not execute using my /bin/bash or my normal PATH of commands? Although, I can’t imagine which PATH would not include mkdir or rm.

0 Likes

Sublime Text 3 to use zsh shell
#2

No one?

Does bash not work from Sublime 2 on OS X?

0 Likes

#3

Hi,

Came across this quite a while after your post so not sure if you’re still looking for an answer.
But I may be able to provide a hint.

I ran into a problem with a command not being on my path in GUI apps on OS X.
To debug the PATH variable that Sublime is getting you can open the python console: **ctrl+` ** and then type:

import os
os.environ'PATH']

default path for GUI apps in osx is /usr/bin:/bin:/usr/sbin:/sbin so it should find those commands you listed in your /usr/bin but if you’ve somehow overriden the default GUI PATH variable via ~/.MacOSX/environment.plist or something you may need to fix it.

If you verify that /usr/bin is in that path then maybe Sublime isn’t starting the script in such a way that it inherits the PATH? Have you tried removing “shell”: true? Or maybe making the “cmd” : “bash”, “./sublimeAntDeploy.sh”, “$file”] ?

Sorry I can’t give a more definitive answer.

0 Likes

#4

Ok, weird.

So I read what you said and decided I’d open sublime and see what’s up again… Works now. Sooooooooooo…

No clue what it was.

0 Likes

#5

It seems if Sublime is started from the Finder / Explorer then the path is the system default.
When I start Sublime from the Terminal then the PATH vat is the same as my shell.

Setting sublime so that it can start from the Windows command line is possible.
But I do not know a method of starting Sublime from the Finder / Explorer and also taking the system path along with it.

Brian

0 Likes