Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Safe scripting



Hi,

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?

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



Messages sorted by: Reverse Date, Date, Thread, Author