* Question about exception
@ 2005-12-11 22:58 MARG
2005-12-12 1:06 ` Glynn Clements
2005-12-12 17:56 ` Jeff Woods
0 siblings, 2 replies; 3+ messages in thread
From: MARG @ 2005-12-11 22:58 UTC (permalink / raw)
To: linux-admin
Hi,
I'm making this BASH script to install a ful web system in Linux:
-----------------------------------------------------------
#!/bin/bash
#
# Uncompress and pre-configure Apache
#
file="apache_1.3.34.tar.gz"
if [ ! -f "$file" ] ;
then
echo "file '$file' not found" >&2
exit 1
fi
tar -zxpvf $file
base_apache="${file%.tar.gz}"
cd $base_apache
./configure --prefix=/usr/local/httpd
cd ..
#
# Install MySQL
#
file="mysql-5.0.15.tar.gz"
if [ ! -f "$file" ] ;
then
echo "file '$file' not found" >&2
exit 1
fi
tar -zxpvf $file
base_mysql="${file%.tar.gz}"
cd $base_mysql
./configure --prefix=/usr/local/mysql || make || make install
cd ..
#
# Install PostgreSQL
#
file="postgresql-8.1.0.bz2"
if [ ! -f "$file" ] ;
then
echo "file '$file' not found" >&2
exit 1
fi
# and so forth...
-----------------------------------------------------------
I'd like to abort the whole script, if some package compile aborts with
an error.
For example, if there is an error compiling MySQL, i don't want the
script to follow to PostgreSQL.
I want it to abort with an error.
How can i do this ?
Any help would be apreciated.
Warm regards,
MARG
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about exception
2005-12-11 22:58 Question about exception MARG
@ 2005-12-12 1:06 ` Glynn Clements
2005-12-12 17:56 ` Jeff Woods
1 sibling, 0 replies; 3+ messages in thread
From: Glynn Clements @ 2005-12-12 1:06 UTC (permalink / raw)
To: MARG; +Cc: linux-admin
MARG wrote:
> I'm making this BASH script to install a ful web system in Linux:
> I'd like to abort the whole script, if some package compile aborts with
> an error.
> For example, if there is an error compiling MySQL, i don't want the
> script to follow to PostgreSQL.
> I want it to abort with an error.
>
> How can i do this ?
( ./configure ... && make && make install ) || exit 1
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question about exception
2005-12-11 22:58 Question about exception MARG
2005-12-12 1:06 ` Glynn Clements
@ 2005-12-12 17:56 ` Jeff Woods
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Woods @ 2005-12-12 17:56 UTC (permalink / raw)
To: MARG; +Cc: linux-admin
At 22:58 +0000 12/11/2005, MARG wrote:
>#!/bin/bash
#!/bin/bash -e
or
set -e
or
set -o errexit
and (if desired) disable by
set +e
or
set +o errexit
All three toggle the same "errexit" option.
--
Jeff Woods <kazrak+kernel@cesmail.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-12-12 17:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-11 22:58 Question about exception MARG
2005-12-12 1:06 ` Glynn Clements
2005-12-12 17:56 ` Jeff Woods
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).