So you want to start programming UNIX shells. You could sit down with a dense volume of coding advice, but you’re a techie. You want to jump right in and start coding. This chapter will help you get started right away with shell programming in UNIX.
UNIX Shell Programming QuickStart
2005-01-24 Unix 5 Comments
might as well read informit!
If your going to write anything more than a 5 line script avoid csh , bash etc.. like the plague. I have found shell scripts result in big messy hard to debug monstrosoties. Also adding extra features that users want becomes a nightmare. Your tiny trivial shell script can become a huge mess very quickly. For working on the command line bash and csh are great but for developing permanent scripting solutions use python or ruby instead:)
I agree that large shell scripts can get very messy; but some are quite clean, organized, and work very well. A lot depends on your knowledge of the shell that you use. Lately I’ve been doing more scripts using retroforth than bash, but I’m far more familiar with retroforth than with bash
If you’re writing shell scripts in (t)csh or bash you are allready looking for troubles. /bin/sh is your friend.
I like bash scripting. I can test individual commands very easily, and I learn to understand my commands a lot better.
To avoid the mess I tend to organize things in functions that take arguments and that pipe their output to some channel. You can have more than the stdout and stderr, and let the user decide were it should go -> this way I split up different outputs in a single function. I have to admit that I have only used some other channel once though.
Anyway, my point: I think bash shell scripting isn’t all bad… You do have to clearly comment what you do in a normal language though, because indeed, commands can get complex very quickly (which is partly why I like bash scripts).