[ale] [ANNC] ALE CENTRAL MTG. for Thurs., May 20th, 2010

Brian Pitts brian at polibyte.com
Wed May 19 00:16:49 EDT 2010


On 05/18/2010 11:53 PM, Jim Kinney wrote:
> And now we know the _real_ reason it's called "bash"

Bang splat bin bash indeed. I wish I could be there for this
presentation, and I hope that its content will be (or perhaps already
is) available online.

There's always more to learn with bash! If you're like me, you learn it
and then forget it. Here's a handy approach to writing bash scripts I
only discovered last week.

> #!/bin/bash
> set -e
> 
> function cleanup {
>     set +e
>     false
>     echo "cleaned up"
> }
> 
> function errorreport {
>     echo "reported error"
>     exit 1
> }
> 
> trap cleanup EXIT
> trap errorreport ERR
> 
> eval $1
> echo "end of the script"

$ ./traptest true
end of the script
cleaned up

$ ./traptest false
reported error
cleaned up

-- 
All the best,
Brian Pitts


More information about the Ale mailing list