(patch for Bash) try-block and exception
From: William Park (opengeometry_at_yahoo.ca)
Date: 07/31/04
- Next message: Peter Jacobi: "Re: Codecs for ISO 8859-11 (Thai) and 8859-16 (Romanian)"
- Previous message: Raymond Hettinger: "Re: metaclasses and Exceptions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Jul 2004 18:44:06 GMT
(crossposted to comp.lang.python, because this may be of interest to
them.)
Python has try-block, within which you can raise exception. Once it's
raised, execution breaks out of the try-block and is caught at the end
of try-block.
Now, Bash has similiar feature. I've added try-block and 'raise'
builtin into Bash-3.0. Typical usage would go something like
try
echo a
raise
echo b
done
or
try
echo a
raise 2
echo b
done in
0) echo okey ;;
1) echo raised 1 ;;
2) echo raised 2 ;;
*) echo really bad ;;
esac
The exception is positive integer and is raised by 'raise' builtin, just
like 'break' for the for/while/until loops. And, it can be caught by
using optional case-like statement.
Ref:
http://freshmeat.net/projects/bashdiff/
help try
help raise
-- William Park, Open Geometry Consulting, <opengeometry@yahoo.ca> Toronto, Ontario, Canada
- Next message: Peter Jacobi: "Re: Codecs for ISO 8859-11 (Thai) and 8859-16 (Romanian)"
- Previous message: Raymond Hettinger: "Re: metaclasses and Exceptions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|