Saturday, November 18, 2006

She Sells Sea Shells

I've been thinking I should investigate shells. No, not seashells, silly, but rather command shells. I've always used bash, but more because I do so much of my work on Linux and it is the default shell then any real comparison between any of the myriad shells offered. Some people are voracious tcsh defenders, which is the "out of the box" shell found on FreeBSD (and, of course, PC-BSD). Other popular shells include ksh (kornshell), pdksh (a very close ksh relative), and zsh. And I won't get into the ancient ones, like sh (the original Bourne shell) and csh, as those are old and crufty, although 'sh' is the scripting language of choice, due to its power and widespread availability.



Anyway, I was reading FreeBSD 6 Unleashed on Safari (pretty good service, an article for another day), when I came across the chapters on command lines, and the part where they talk about the various shells. It was a very good overview of the various shells, ending with:




Which Shell to Choose?


Which shell, then, should you choose? For most of this chapter, it doesn't really matter. Most of the standard FreeBSD commands work the same way under all shells. It is only when you want to start performing advanced tasks, such as changing shell variables, setting aliases, and writing shell programs, that the differences between the shells really become apparent. In day-to-day use, you'll find that some of the features of more advanced shells (such as the ability to recall your previously issued commands using the arrow keys, and to complete command names with the Tab key) are crucial to your ease of use and peace of mind. This means using pdksh, bash, or the shell endorsed by FreeBSD, tcsh.



If you don't plan to do any shell programming, tcsh (which in FreeBSD is the same thing as csh) is a fine choice. If you are interested in learning shell programming, choose pdksh or bash because you won't have to unlearn anything when you start programming, and all the commands you learn for operating within the shell can be applied directly to programming within it.





So I suppose I should just tackle tcsh, a shell that I used to use in days gone by, but haven't done much with lately. But although they didn't mention zsh in this overview, their description was intriguing enough that I thought I would give it a try:



The zsh Shell



The Z Shell, or zsh, is a shell designed to cover all the bases. Its basic design is Korn-like, and it incorporates all the popular features of both bash and tcsh (and it attains a large size and memory footprint because of it); but its unique features such as advanced globbing (filename matching), command line editing, and key binding makes it a favorite for hard-core UNIX users, especially those accustomed to the binding-rich Emacs editor.



It was that bit about Emacs that attracted me, of course, being the Emacs aficionado that I am. So I've installed zsh and am playing with it a bit. The initial setup is quite daunting! There is a very long customization script that runs to get some things set up, and there is surely enough options to keep me dizzy for weeks. I'm going to be playing with it over the next few weeks to see how it works out and if I can notice any major differences in daily usage.



I also want to get much more into scripting. It's something I used to do quite frequently on Windows, ironically enough, where I've been using the incredibly powerful 4nt for ten years or more and find it very intuitive to write small batch files to do my work. But I've never felt comfortable enough with sh or bash to do the same on Unix / Linux. But now that PC-BSD is my everyday environment, I figure I must get better at it.



Addendum: Here is another excellent overview of the popular shells: UNIX shell differences




No comments:

Post a Comment