I am using MacOS Monterey version 12.0
I checked in root directory, I don't have .bashrc
and .bashprofile
, but my system is using .zshrc
and .zprofile
I am getting error that
./bin/temp.sh: line 3: /Users/xyz/.bashrc: No such file or directory
Code of temp.sh
file at line 3 :
#!/usr/bin/env bash
source ~/.bashrc. # This line is causing error
Temporarily, I replaced this line with below and it is working
#!/usr/bin/env zsh
source ~/.zshrc. # This is working fine !!
From searching over few answers and posts, I got to know that Mac systems are transitioning to zsh
from bash
, because zsh
is improved version of bash
Can anyone tell me proper solution of routing .bashrc
or .bashprofile
commands to fetch internally .zshrc
or .zprofile
?
what will be best solution so that same script file can run on both systems having zsh
and bash
shells?
If you want your script to use
zsh
, you will need to replace the first line which calls your shell, to make it callzsh
instead ofbash
:And then make sure your script isn't using anything specific to
bash
, or adapt the script to replace tit's "bashisms" with the zsh-specific equivalents.Alternatively, you could also just create the file you need to
source
with the content you want. The real question is why is your script trying to source.bashrc
? Which variables/functions/whatever does your script want to initialize from there?