I have an alias set up in my .bash_profile file: alias local='npm run start-local'
, and for whatever reason when I open a new terminal session it is trying to run that command npm run start-local
immediately. It works fine if I rename it to "local2". What could be causing this?
I got this alias from my coworker who uses it regularly, and the only difference I know of is that he is not on Mojave.
Edit: something interesting I noticed is that if I change it to alias local='echo '
then I see
NVM_AUTO_MODE
NVM_CURRENT
NVM_MODE
VERSION
-bash: fork: Resource temporarily unavailable
Which adds evidence that it is running my local command when something is trying to use the local variable.
Best Answer
I could not recreate what you have said is happening to you.
Saying that I would say that: It is really very dangerous to invoke
local
as youralias
Because the word
local
is a shell builtin, a reserved word for the default Bash shell to define a local variable in Bash script inside a Bash function. If you dotype local
from a new terminal window after removing it from youralias
or byunalias local
and then you would see it says:That is why, when you changed your
alias
tolocal2
fromlocal
it worked fine sincelocal2
is not a shell builtin.However, if you are using Korn Shell (version 93u+),
local
is not a shell builtin there. But, in most other shellslocal
is a reserved word or shell builtin. So, in short:local
should not be stored as analias
For more information about shell builtin, look at man page:
man builtin
Also, as mentioned by Gordon Davidson, there is definitely something calling the
local
variable and since you have overridden it as an alias fornpm
, it is running each time you are opening a new session.