You are not logged in.

#1 2010-01-29 10:03:32

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

What about using `set -e'

I noticed we usually use || return 1 to break the build function in case or errors.
It works, but you have to recall to put it almost everywhere.

I was thinking, what about using `set -e' at the start of the function? *
So the build() function would fail automatically if any subcommand returns non zero,
if a command can return nonzero we will add `|| true', but it is much rarer.

this snipped from one of the PKBUILD protos

build() {
  cd "$srcdir/***-$pkgver"

  # install module in vendor directories.
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
  make || return 1
  make install DESTDIR="$pkgdir/" || return 1
}

would become:

build() {
  set -e
  cd "$srcdir/***-$pkgver"

  # install module in vendor directories.
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
  make
  make install DESTDIR="$pkgdir/"
}

*Seek '^ +set \[\+' (no quotes of course) in the bash manual.

Last edited by ezzetabi (2010-01-29 10:05:33)

Offline

#2 2010-01-29 10:09:18

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: What about using `set -e'

Sounds not bad. But don't forget to add `set +e` at the end of build()


This silver ladybug at line 28...

Offline

#3 2010-01-29 10:35:09

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,671
Website

Re: What about using `set -e'

Or wait for the next pacman release where this is done automatically.

git commit: http://projects.archlinux.org/pacman.gi … d=545eac14

Offline

#4 2010-01-29 10:44:50

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: What about using `set -e'

Oh... :S

Offline

Board footer

Powered by FluxBB