Terminal pAtHs and AS PaThS


Anyboby know why when I type this in terminal:

bash-2.05a$ sh
sh-2.05a$ echo $path
sh-2.05a$ echo $PATH

I get that and in AppleScript:

do shell script “echo $path”

→ “$path:/usr/local/bin”

do shell script “echo $PATH”


You see hos the $PATH is different with sh. Is AppleScript running a different sh shell? I tried looking on the internet for the sequence of configuration files for sh, but just could find that it starts with the /etc/profile config file.


Think I got the answer. I have to create an ENV file and set the ENV variable to some file. Need to go back and read the instructions. Head hurts.

I don’t have a very good understanding of this, but from what I’ve heard, the default shell that terminal runs is bash (and the default for the system), while AppleScript prefers to run sh.


echo $SHELL


do shell script "echo $SHELL"

.returns ‘/bin/bash’ for both, but doing.

echo $BASH


do shell script "echo $BASH"

.returns ‘/bin/bash’ from the Terminal, and ‘/bin/sh’ from AppleScript.

Hi Qwerty,

Yeah, I don’t think do shell script uses sh. I think it’s using bash even though it’s returning /bin/sh. The reason why I say this is because I configured it to use ~/.profile to set the environment variable ENV to us a file ~/.shinit which sets the PATH variable, but the shell is not even looking at the ~/.profile config file.

I’m attempting to set the PATH the bash way for the do shell script.


Nope, didn’t work. I guess I just need to use the full path to everything.

Thanks anyway,

good info here:


go down to, “8.2 Search Path”.


Hi waltr,

That article answered the question!

I tried the ~/.MacOSX/environment.plist before and deleted it thinking it didn’t work. But, I didn’t logout of the system and back in. Later on, I hd changed the default shell with NetInfo Manager and the changes didn’t take place until I logged out. After changing the default shell and running a ‘do shell scirpt’:

do shell script “echo $SHELL”

the result would be the old defualt shell. So, I did know that things were set in the ‘do shell script’ at login to the system, but didn’t know that the environment.plist file pertained to logging in. I’m still wondering where the ‘do shell script’ command is getting its information without the environment.plist file existing.

If anyone wants to know to add the plist.

First see if ~/.MacOSX/environment.plist exists. If not create the path to it. In Terminal I used ls, mkdir, and pico. Added to the plist this:

<?xml version="1.0" encoding="UTF-8"?> PATH /bin:/sbin:/usr/bin:/usr/sbin:/Library/Tcl/bin:/usr/local/bin

Not sure if you can use $PATH at the beginning of the string:


but I just used the whole thing to make sure.

Thanks a lot,

kel, I’ve found that we were both semi-correct:

(Source: Introduction to Open Source Scripting on Mac OS X)
So AppleScript does uses /bin/sh, which is really just bash in disguise.