I have script that used curl 
when i pass wrong parameters to script curl failed but script continue executing.
I have tried use curl -f/--fail parameter but problem does not solved.
What is the best way to stop script?

I have founded my mistake.
I used curl command into another command 

echo `curl --fail ... || exit 1`


After removing echo command curl become working properly.
Thank you for answer, it is also useful.


Question: how can i use regex to get a certain string of a file
Answer: #!/bin/sh
a="2010.04.18Myfile.tgz"
echo ${a%%+([a-zA-Z.])}


bash' regexp are quite powerful (at least compared to standard sh or command.com :-))