Re: set -e in bash (long)

Baho Utot <[email protected]>
Newsgroups gmane.linux.lfs.general
Message-ID <[email protected]>
On 11/20/2012 12:27 PM, Ken Moffat wrote:
> Hi All,
>
>   I'm revising my buildscripts (long, _slow_ process) and as part of
> that I'm changing from prodigious use of '&&', with tests of "$?"
> when necessary, to 'set -e' and relying on the script to fail.  But
> I'm having some results that aren't what I expected - advice would
> be welcome.  Long details, for those who care:
>

[putolin]

I use trap that has a function

trap '_errortrap "Caught error processing\n";exit 1' ERR INT

_errortrap() {
     local i=$1
     printf "${i}: Build failure...\n"
     touch ${FAILURE}
     exit 1
}

I then do something like this those parts that are in loops etc.

Some_statement || _errortrap

I also place a file called FAILURE into the parent fiesystem and test 
for it when I start a new package for build.

for i in list of ${stuff_to_build}; do
     [ -e ${FAILURE} ] && 'errortrap
     build_package
     do_stuff
     etc
done

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.