This is a discussion on shell script question within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I have a shell script that builds a bunch of source archives one after another. Here's an excerpt: echo ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have a shell script that builds a bunch of source archives one after another. Here's an excerpt: echo Installing Sh-utils-2.0 tar -xzvf sh-utils-2.0.tar.gz cd sh-utils-2.0 patch -Np1 -i ../sh-utils-2.0.patch LDFLAGS="-static" ./configure --prefix=$LFS/static \ --disable-nls make make install cd .. rm -rf sh-utils-2.0/ echo Installing Tar-1.13 tar -xzvf tar-1.13.tar.gz cd tar-1.13 patch -Np1 -i ../tar-1.13.patch LDFLAGS="-static" ./configure --prefix=$LFS/static --disable-nls make make install cd .. rm -rf tar-1.13/ How do I trap errors from make, patch, etc., and exit the script if there is an error? TIA |
| |||
| On Fri, 7 Nov 2003, chud wrote: > I have a shell script that builds a bunch of source archives one > after another. Here's an excerpt: > > echo Installing Sh-utils-2.0 > tar -xzvf sh-utils-2.0.tar.gz > cd sh-utils-2.0 > patch -Np1 -i ../sh-utils-2.0.patch > LDFLAGS="-static" ./configure --prefix=$LFS/static \ > --disable-nls > make > make install [...] > How do I trap errors from make, patch, etc., and exit the script > if there is an error? assuming yer running your script in a bash shell, (probably true), you can use stuff like: make install || ( echo "ERROR: $? make install" && exit 1 ) if you want to use lots of errortesting, it's handy to a have: function errorexit () { echo ERROR: $* exit 1 } then, yer script can simply say: make install || errorexit $? make install -- William Hunt, Portland Oregon USA |
| ||||
| On Fri, 07 Nov 2003 12:30:58 -0800, William Hunt wrote: > > assuming yer running your script in a bash shell, (probably true), > you can use stuff like: > > make install || ( echo "ERROR: $? make install" && exit 1 ) > > if you want to use lots of errortesting, it's handy to a have: > > function errorexit () { > echo ERROR: $* > exit 1 > } > > then, yer script can simply say: > > make install || errorexit $? make install Thanks much. That's what I was looking for. |
| Thread Tools | |
| Display Modes | |
|
|