Shell Scripting

Andy Price andy-price at ubuntu.com
Fri Jun 1 01:06:24 BST 2007


On 31/05/07 21:40, charliej wrote:
> For the MOTU hopefuls that have a very limited understanding of shell
> scripting (such as myself) I have found a very good Beginner's Handbook.
> 
> http://www.freeos.com/guides/lsst/index.html
> 
> This actually helped me get my postinst to the point where lintian isn't
> complaining anymore.  I found it to be very useful.

Good find. While we're on the subject of shell scripting, here are some
neat tips I've picked up over the years:

While you're in bash, you can type "help foo" to get some help about the
"foo" shell command. I sometimes use it to remind myself of the syntax
of loops and things. Typing "help" on its own gives you a list of shell
commands. "man [" is also handy for looking up the tests you can use in
if-statements e.g. "if [ -d /foo/bar ]" means "if /foo/bar exists and is
a directory".

Also, Ubuntu uses a sh-like shell called dash as the default /bin/sh, so
make sure your scripts don't contain bashisms. There's a script called
checkbashisms in the devscripts package for this very purpose.

Hope that helps

--
Andy Price
http://andrewprice.me.uk



More information about the Ubuntu-motu-mentors mailing list