shreyasm-dev
shreyasm-dev

Reputation: 2844

Shell script does not recognize alias

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?

Upvotes: 2

Views: 970

Answers (1)

user1934428
user1934428

Reputation: 22356

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

setopt aliases

before defining your alias.

Upvotes: 4

Related Questions