Shopt: command not found

I have largely customized my configs to my liking, including by incorporating my bashrc and zshrc files in my home.nix file. One annoying thing I’ve noticed though is that whenever I open a terminal and it starts Zsh I get the messages:

shopt: command not found
shopt: command not found
shopt: command not found
shopt: command not found
shopt: command not found

My configuration files are here. To fix this problem, I’ve tried adding:

programs.zsh.shellInit = "export PATH=$PATH:/run/current-system/sw/bin:/run/current-system/sw/sbin"

to my configuration.nix file, but this hasn’t fixed the issue.

shopt is not an executable and is not on the path.

It is a bash builtin and not in zsh. Thus it should not be in any file that zsh reads.

You need to look at all the files that zsh reads on startup and see which one has had bash commands added to it.

4 Likes

Thank you. I guess that’d be a consequence of my zshrc file sourcing my bashrc. Mystery solved. I’ll just define an empty shopt function.

No

There are other differences between bash and zsh

If you have plain POSIX commands that can go in both zsh and bash put them in a separate file and source that file from .bashrc and .zshrc Or put those common ones into a string and appened them to the shellInit strings in your nix configuration.

You have to look at each line and see if it is zsh, bash or POSIX

Also zsh has an equiavlen to shopt - setopt which is a zsh built-in, and put those values into your .zshrc script. So if you need shopt in bash then you need to put the equivalent in zsh or else you might as well delete those lines as you have said you do not need them

1 Like