Shell script does not recognize alias

Viewed 499

I have a file named run. These are the contents:

#!/bin/zsh

python

To make the file executable, I ran chmod a+x run. I typed in ./run into the terminal. It activates the Python 2.7 shell. The reason this is unexpected is because in my .zshrc file I have an alias: alias python="python3". Why does zsh not recognize my alias?

1 Answers

You need to enable alias processing. Do in your script a

setopt aliases

before defining your alias.

Related