Shopt Command Not Found In. Bashrc After Shell Updation
I Have Updated My Shell to Zsh. When I Source ~/. Bashrc. I Am Getting This Error There Was Some Error in Yo Doctor. When I Execute This Command Echo "Export...
I have updated my shell to ZSH. When I source ~/.bashrc. I am getting this error
There was some error in yo doctor . when i execute this command
echo "export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules" >> ~/.bashrc && source ~/.bashrc
/home/amerrnath/.bashrc:17: command not found: shopt /home/amerrnath/.bashrc:25: command not found: shopt /home/amerrnath/.bashrc:109: command not found: shopt /usr/share/bash-completion/bash_completion:35: parse error near `]]'
Please help me resolve this problem
zsh uses env profile ~/.zshrc, not ~/.bashrc.
so you need to append your env settings to .zshrc file and then
source ~/.zshrc
It must work.
To place anything in ~/.bashrc:
Switch to bash:
exec bash
Then
source ~/.bashrc
Switching to bash will not effect on new terminal window. But if you want to switch current window to zsh.
Switch to zsh:
exec zsh
shopt is not a command, but a shell built-in. bash knows what to do with it because it's a bash built-in , but zsh has no idea what it is. You'll want to look into setopt which is a zsh built-in, and put those values into a new .zshrc script.
Make an alias of shopt and call it through zsh
A quick solution is described here:
sudo vi /usr/bin/shopt
Inside the shopt
#!/bin/bash
args='';
for item in $@
do
args="$args $item";
done
shopt $args;
make it executable
sudo chmod +x /usr/bin/shopt
Create an alias in your .zshrc
echo "alias shopt='/usr/bin/shopt'" >> ~/.zshrc
Your bashrc file was written for bash. zsh is not bash.
I'm surprised zsh is trying to load your .bashrc at all.
If it isn't and you are sourcing it manually (from .profile or similar). Stop doing that.
Then you get to write an appropriate zsh init file instead.
If you want to use zsh then you need to use zsh and not bash.
shopt is a bash-ism.
[[ is a bash-ism.
shopt is not a command, but a shell built-in. You can find out this by running the following command in bash:
type shopt
output would be:
shopt is a shell builtin
solution:
step1:
echo "#! /bin/bash\n\nshopt \$*\n" > /usr/local/bin/shopt
then you will get /usr/local/bin/shopt:
#! /bin/bash
shopt $*
step2:
chmod +x /usr/local/bin/shopt
step3:
ln -s /usr/local/bin/shopt /usr/bin/shopt
step4:
echo "alias shopt='/usr/bin/shopt'" >> ~/.zshrc
Most of the time will be that your are trying to execute a bash command within the zsh shell
swich to bash with
exec bash or
bash
Then go ahead and type
source .bashrc
For some reason after the upgrade from 16.04 to 17.10 and to 18.04, the symlink /bin/sh was set back to dash not bash. Updating this link:
sudo cd /bin && ln -sf bash sh
solved this problem for me