There is a pbi for bash. So rather than pkg_add you can use the pcbsd package--6 of one, half a dozen of the other. The advantage to the pkg_add is that it will add bash automatically to /etc/shells
The pbi packages doesn't do that and you will have to manually add a line /usr/local/bin/bash to /etc/shells.
Then, to make it your default shell
|
Code:
|
chsh -s /usr/local/bin/bash |
PCBSD uses csh by default. That is the default shell for root in FreeBSD. Many people feel that it is a horrible shell for scripting, but this is a matter of personal taste.
Without writing a book, basically it works this way. FreeBSD's csh is actually tcsh which, like bash has history and tab expansion--that is, if you type part of a file name and hit the tab key, it will complete the name for you or give you a list of possibilities.
The sh shell which is closer to bash, doesn't have tab exansion or history with the arrow keys. These are the two shells that ship with the system and are located in /bin. (This can be handy if, for some reason, you can't mount /usr, which is where other shells installed from ports will be.)
Getting curious about this, I once googled to find out why--apparently, the first developers simply preferred the csh shell to the bourne style shells, therefore, the improved csh was chosen as the more advanced shell to be included with the O/S.
NetBSD has these two (though not sure if their csh is tcsh or not). However, NetBSD also has the korn shell, ksh, which is more similar to bash and other Bourne style shells. As of 2.0, their ksh also has tab expansion and history--prior to that, it didn't have them set automatically.
I have to somewhat disagree with sblevin. Depending upon your needs, you don't need to learn scripting with csh, I would say very few people use it for that.
The sh shell IS often used for scripting. The man reason is that it is portable--that is, if I write a bash or my personal favorite, zsh script, then port it to an AIX box running ksh, it might not work. However, if I write a sh script, then just about ever Unix and Unix clone out there has it.
If you're using GNU/Linux, then it's probably safe to stick with bash, but if you go to a different *nix, then you might have portability problems. For example, sh doesn't have the select loop.
I would install bash and use it for my every day work. I'm more familiar with it than I am with csh, and it's simply more convenient for me to use either bash or zsh.
When you are used to tab completion and history, using sh can be annoying--you hit the tab key and it simply advances however many spaces your tab is set to advance.

For most things, if, for example, I was in single-user mode and hadn't yet mounted /usr, I would probably use csh, because the FreeBSD version does have tab completion.
For scripting, try to use sh. Sometimes, you need a feature of bash, or another shell, but it will lessen the script's portabilty. Of course we all get into habits. For awhile, I was doing a temperature conversion script with zsh, which handles floating decimals. Bash doesn't.
Then, feeling I would rather use sh, I changed it around--FreeBSD has bc, a math program that handles decimals, as a built in command. However, I then used the program on some Linux distro or another and ran into trouble because they didn't have bc as a builtin command--it had to be installed.
The point being, portability can often be an issue. Many people are used to the Linux seq command. FreeBSD has jot which is similar but not identical.
I think I lost my original point.

Anyway, install bash--if you use the pbi, then add it to /etc/shells. Make it your default shell as I described. However, as sblevin says (hrrm, may I call you sb?--it's easier to type) you should become at least passingly familiar with the builtin FreeBSD csh and sh. Become familiar enough with csh to use it in emergencies (at the basic level, that is, if you're not scripting, there aren't too many drastic differences) and familiar with sh if you want to write shell scripts.
(As far as sh goes, the differences are basically the things that bash has that sh doesn't, such as the above-mentioned select loop).