-4

I was recently unable to answer what the differences between the fish shell and the bash shell were. Some of my questions deal with --> How come bash uses .bashrc and fish doesn't? I would really appreciate it if someone could shine some light on the subject. Note: This question doesn't just pertain to fish and bash rather it pertains to most shells alike.

1
  • Fish and Bash are different like Firefox and Chrome are; they are different programs to do the same thing. And of course Fish does not use ~/.bashrc just like Chrome does not use your Firefox settings.
    – fkraiem
    Nov 14, 2017 at 1:30

1 Answer 1

1

The different shells support different commands and syntaxes. While the commonly used ones are somewhat compatible with the Bourne shell (predecessor to bash, the POSIX shell standard, and many other shells), they do vary. In particular, bash adds a lot of features not available in those other shells.

"bash" is a contraction of "Bourne again shell", a reference to the shell it was intended to supercede.

How come bash uses .bashrc and fish doesn't?

Because .bashrc is specific to bash. Most people use bash as their interactive shell, even if they use a different shell for executing scripts. Using .bashrc to set up your bash interactive environment allows you to put things in there that will only work on bash.

An alternative to .bashrc which is not bash-specific is .profile. The commands in .profile are intended to be used for any shell used interactively (the concept of .profile originated with the Bourne shell).

Note that .bashrc is read by non-login shells (eg subshells of your login shell) whereas .profile isn't.

4
  • Could you also please clarify what is the point of /etc/profile. I believe this file is executed on every user login? Am I correct or is there more to it?
    – NerdOfCode
    Nov 13, 2017 at 23:29
  • It's a script that runs whenever you start a login shell. A common use is to set up any environment variables you are likely to always want. Nov 14, 2017 at 1:24
  • 1
    Pedantically, .profile is used for POSIX-type shells like bash, ksh, dash. fish, tcsh, zsh don't use it. Nov 14, 2017 at 2:24
  • One could add that fish has a config file equivalent to .bashrc: ~/.config/fish/config.fish
    – dessert
    Nov 14, 2017 at 9:21

Not the answer you're looking for? Browse other questions tagged .