Jump to content

/bin/zsh for shell language


Recommended Posts

I believe Andrew has said that none of the user-specific environment settings are loaded when shell scripts run. This is to make them able to be transferred freely to other users without compatibility issues. You just have to make sure you call the full path rather than any aliases you have set up. For example, in my own (bash) scripts, I can't just use "growlnotify" like I normally would, I have to put the whole "/usr/local/bin/growlnotify" into my scripts. Personally, if it's a command I'm going to be using a lot, I just manually add an alias at the top of the script. Or just do a find-replace when you're done. ;) )

Link to comment
Share on other sites

Strangely, when I alias, I cannot execute the binary:

 

 

 

#!/bin/zsh


alias audiodevice="/Users/Oliver/.bin/audiodevice"


audiodevice

This doesn't work. Nothing is echoed, thus the `audiodevice` binary is not running.

 

If I do this, however, it works:

 

 

 

#!/bin/zsh


/Users/Oliver/.bin/audiodevice
Link to comment
Share on other sites

I don't know if it's the same for zsh, but for bash I discovered (thank you Google) that aliases aren't loaded by default when running scripts.

 

I had to add this to the top of my scripts:

 

 

#Enable aliases for this script
shopt -s expand_aliases

 

 

 

which did the trick.

 

Hope that helps.

Link to comment
Share on other sites

I don't know if it's the same for zsh, but for bash I discovered (thank you Google) that aliases aren't loaded by default when running scripts.

 

I had to add this to the top of my scripts:

 

 

#Enable aliases for this script
shopt -s expand_aliases

 

 

 

which did the trick.

 

Hope that helps.

Very helpful. Cheers.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...