Bourne shell (/bin/sh) and Tcsh configuration

Hi!

First of all I am glad to be back in the FreeBSD community. I haven't had a chance to work with FreeBSD since 6.2 I think. I mostly worked with flavors of Linux, so bash was my shell all these years. I could just install it from ports and forget about it, but I would like to avoid installing it on my sytems, since I believe FreeBSD built-in shells should be enough (unless you can prove me wrong).

OK, to the questions:

To my surprise I noticed that /bin/sh is actually very capable nowadays (at least on 9.0-RELEASE). It seems it fulfills most of my interactive shell needs, except some.

  1. Is there a way to configure completion? I see from bind output that there is such a thing as sh-complete, but in no man page I can fine any info on this command. I guess it should have been mention in man editrc, but it isn't to my regret. By default it completes directory and file names pretty good. I only miss completing shell commands.
    Code:
    $ bind ^I
    ^I      ->      sh-complete
  2. Is it possible to configure /bin/sh to save interactive shell history to file as tcsh and bash does?

    Now regarding tcsh. Since it is much more complicated than /bin/sh there are lots and lots of options to play around with, but unfortunately I do not at the moment have time. Would be great to have it up and running as fast as I can. I mean defaults are OK to some extent, but I miss having to press ^D for completions instead just tabbing my way through.
  3. Configure tcsh completion to work with [Tab] key only?
  4. Any other configuration options for an ex-bash user?
 
Unfortunately, sh(1) doesn't support command completion, only path completion.
Same is true for a history file. :(
 
sh() is a posix compliant shell meant for scripting. It's meant to have no (or few) interactive features to provide speed of execution:

http://www.freebsd.org/doc/en/books/faq/applications.html#MINIMAL-SH
7.10. Why is /bin/sh so minimal? Why does FreeBSD not use bash or another shell?

Because POSIX® says that there shall be such a shell.

The more complicated answer: many people need to write shell scripts which will be portable across many systems. That is why POSIX specifies the shell and utility commands in great detail. Most scripts are written in Bourne shell, and because several important programming interfaces (make(1), system(3), popen(3), and analogues in higher-level scripting languages like Perl and Tcl) are specified to use the Bourne shell to interpret commands. Because the Bourne shell is so often and widely used, it is important for it to be quick to start, be deterministic in its behavior, and have a small memory footprint.

The existing implementation is our best effort at meeting as many of these requirements simultaneously as we can. In order to keep /bin/sh small, we have not provided many of the convenience features that other shells have. That is why the Ports Collection includes more featureful shells like bash, scsh, tcsh, and zsh. (You can compare for yourself the memory utilization of all these shells by looking at the “VSZ” and “RSS” columns in a ps -u listing.)

If you're interested in interactive features use csh and write your shell scripts in sh. If csh isn't your thing simply install one of the bourne derived shells from the ports and use it for interactive use. If you haven't had an opportunity zsh is a bourne/korn style shell with a large feature set when it comes to completion systems.

All bourne derived shells (ba|k|z)sh are compatible with ash syntax.
 
Back
Top