Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Safe scripting
- X-seq: zsh-users 13731
- From: Atom Smasher <atom@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Safe scripting
- Date: Wed, 21 Jan 2009 22:53:04 +1300 (NZDT)
- In-reply-to: <gl6qnd$63s$1@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Openpgp: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt
- References: <gl6qnd$63s$1@xxxxxxxxxxxxx>
On Wed, 21 Jan 2009, Thorsten Kampe wrote:
what is the best way to detect errors in a (zsh) script?
Or to be more specific: shell scripts (in contrast to other scripting
languages) keep on running even if an error occurs. How can I detect
errors in a script and exit if one occurs?
====================
TRAPZERR () {
print "something went wrong" >&2
exit 1
}
more info in the zshmisc man page.
or...
cd foo && \
rm bar && \
cd foobar && \
rm foobarbar
Say, I have a sequence of commands that all depend on each other:
cd foo
rm bar
cd foobar
rm foobarbar
I could query each commands return code like
if cd foo;
then if rm bar;
then if cd foobar;
then rm foobarbar; fi; fi; fi
But of course that looks to weird. So what would you suggest?!
Thorsten
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"Patriotism is your conviction that this country is superior
to all other countries because you were born in it."
-- George Bernard Shaw
Messages sorted by:
Reverse Date,
Date,
Thread,
Author