What is your favorite shell?

What shell do you use with FreeBSD? Why do you use it? What do you like about it?

I’m currently using FreeBSD sh(1) because it’s lightweight, simple, and for the most part, compatible with Bash (the opposite is not true), which is the lingua franca in Linuxville.
 
At the command prompt, I generally use whatever shell the OS has as a default. For scripts I use the shebang line #!/bin/sh because it's cross-platform compatible and POSIX-compliant. Sometimes as the FreeBSD super-user I'll use /bin/sh in a secondary shell, by entering the commands /bin/sh followed by SHELL=/bin/sh. My only (good) reason for doing this is to allow me to copy and paste environment variable assignment statements from text files without editing in the set command required by the native root /bin/csh shell. I can then return to the /bin/csh shell at any time by entering the exit command. I don't think it's a good idea to change the default shell, so I've broken the habit of doing it, particularly for the root account, where I've never done it.

In the past I've written scripts that required bash, and some that required sudo, but now I'm in the proceses of rewriting them all to use sh and su instead. I would have saved myself some trouble if I had only done it that way in the first place, but as it turns out it's really not that much trouble to fix them. IMO and for my purposes, it's well worth whatever trouble it takes to improve cross-platform compatibility.
 
For my day-to-day interactive use, I use shells/zsh (with vi mode enabled). I was introduced to UNIX via shells/bash and shells/ksh on Solaris. When I passed over to Linux for a time, bash was already there so I used it.

I have a number of friends that use ZSH, so I decided to give it a go and found that (certainly at the time) it was more featureful and flexible in configuration than bash. Also it is MIT licensed, and at the time I was trying to reduce the amount of GPL applications I was using.
I tried oh-my-zsh at the start, but it was too much additional 'stuff' to comprehend, and didn't seem to offer me additional, useful, features to trade off learning them. Also, since I work with many shells in a given day which I can't choose and customise, I try to keep my personal shell customisations fairly simple to avoid additional friction on other systems.

For scripting I always use sh(1). For root's interactive shell I've always used tcsh(1), aside from when I want to do longish "one liners" or looping, then I revert to sh(1) interactively much like Vull described, because I use tcsh(1) so rarely I easily forget how to do things like looping in it, and reverting to sh(1) is quicker than checking a man page.
 
Another zsh user here.

In my early UNIX days (that was mostly SunOS) I used csh and tcsh, because it was the default for new users at the place where I worked. But soon I noticed that it sucked for scripting, so I switched to bourne shell (to be more exact: ksh) for scripting. And then I noticed that it sucks to use different shells for scripting and interactive use. Then I started looking for a better interactive shell.

First I looked at bash, because many people used it. But I never was the guy who used something just because many other people did … So I looked further and tried several other bourne-compatible shells. And finally I settled for zsh, because it was the most flexible regarding its configuration. For example, it is way ahead regarding the possibilities configuring your shell prompt, the editor shortcuts, tab completion and various other things. I can work with zsh much faster and more efficient than with any other shell.

I still use the “normal” /bin/sh for scripting (unless I decide that Python is better for the job at hand). The nice thing is that zsh has an sh-compatibility mode (it can also emulate ksh), so you can easily copy&paste fragments from scripts to the command line, try them out, improve them, and copy them back to your script.

By the way, I have an alias su="su -m", so when I switch to root, I get the same shell that I have as normal user, i.e. zsh, without having to modify root's login shell. Note that – for various reasons – it is usually not a good idea to change root's login shell.
 
Thanks for the tip olli@ - Using su -m to retain the non-root user's shell is quicker than the way I've been doing it.
 
Scripts: Plain sh. If the script has to be portable, I actually spend some effort with the documentation for the V7 Korn shell to make sure I don't use any modern extensions.

Interestingly complex scripts: Python. I'm finding that anything that's longer than 30 or 50 lines is better written in an intermediate-level language, you end up with cleaner, more portable code with fewer bugs. That's particularly important since scripts are hard to completely debug (injecting errors is a lot of extra work, and code path that are not tested can have blatant syntax errors and typos, since there is no compiler to do the first level of quality control). I used to also use Perl, and even Ruby and before that Rexx for a while; today I'm down to just Python.

Interactive: Used to be tcsh, but about 10 years ago I switched to bash for every machine. It's relatively featureful, supported on every OS I use (I do a lot of work on Linux), and has the same syntax as sh, so the difference to scripts isn't too large. That was the real reason I abandoned tcsh: The gap in language between the interactive commands and scripts was annoying me.

For interactive use, this is really just a question of personal preference (or religion), to each his own. But it is not just personal preference for script-writing: abuse of specific features (common in Linux where scripts depend on bizarre features that only exist in bash) is just bad software engineering. I've dealt with a system that had a quarter million lines of scripts (the single largest one was 18K lines), written in a bizarre custom shell that derives from pdksh, and was a maintenance nightmare. Much better to use a common base standard and stay portable.
 
Interactive: I've being using tcsh(1) during the last years, before used to shells/bash on Linux, but yesterday I switched to shells/zsh and I am still configuring it but enjoying in general.

Script: I use sh(1) but I just started learning OCaml, and I also learned a bit about using it as script language. I don't know a lot of about it yet but looks good, and I will probably switch to it at some point. HERE and HERE.
 
I'm a big fan of OCaml and typed FP in general. One of the best OCaml resources I've come across recently is this online book.

I've got two books (I started reading the first):

Hitington J. - OCaml from the Very Beginning - 2013
Minsky Y., Madhavapeddy A., Hickey J. - Real World OCaml - 2013

Now I will add the one you indicated in my shelft too.

[EDIT]

Now I need to find out what is that font used in the title "Functional Programming in OCaml". :-/

Ok, found it. Play - looks good to use with x11-fonts/ohsnap.

Thanks!
 
bash, for no apparent reason, it's (almost) POSIX-compatible for trying out scripts, and pretty good as interactive.

OTOH, there's a proposal for importing mksh to base system -- if it works out, I'll most likely will be happy to just use it instead.
 
At the command prompt, I generally use whatever shell the OS has as a default. For scripts I use the shebang line #!/bin/sh because it's cross-platform compatible and POSIX-compliant. Sometimes as the FreeBSD super-user I'll use /bin/sh in a secondary shell, by entering the commands /bin/sh followed by SHELL=/bin/sh. My only (good) reason for doing this is to allow me to copy and paste environment variable assignment statements from text files without editing in the set command required by the native root /bin/csh shell. I can then return to the /bin/csh shell at any time by entering the exit command. I don't think it's a good idea to change the default shell, so I've broken the habit of doing it, particularly for the root account, where I've never done it.

In the past I've written scripts that required bash, and some that required sudo, but now I'm in the proceses of rewriting them all to use sh and su instead. I would have saved myself some trouble if I had only done it that way in the first place, but as it turns out it's really not that much trouble to fix them. IMO and for my purposes, it's well worth whatever trouble it takes to improve cross-platform compatibility.

You are not alone.. I use sh for scripts, tcsh for interactive, inside jails, zsh
 
As login shell tcsh, only because bindkey -k up history-search-backward, otherwise I would preffer to use something meagerer. For trivial system scripts I use sh: I never learned to realy program with sh, I find it idiosyncratic. For scripting programming I use tcl ()and I can recommend it for many reasons.
 
bash and ksh for interactive use

sh for simple scripts (lowest common denominator / portability)

C for anything I cannot script (i.e X11). I don't bother with Python, perl, java and all that stuff because I despise pointless bindings and dependencies which can simply be avoided by using C.
 
Back
Top