Skip to content
Snippets Groups Projects
Commit e1d629b6 authored by Natanael Copa's avatar Natanael Copa
Browse files

abump: fix set -e issue

It appears that when the subshell has a ||, the 'set -e' within
subshell gets invalidated.

This will work as expected:

 ( set -e; false; echo "should not get here" )

While this will not work as expected:

 ( set -e; false; echo "should not get here" ) || false

We resolve it by using $? to detect the status of subshell. We also let
the exitcode indicate how many packages that failed.

While here we also refactor it so most of the loop happens within the
subshell. This lets us set (or increase) rc variable once, and it
reduces number of forks which gives slightly better performance.
parent 5021e13f
No related branches found
No related tags found
No related merge requests found
...@@ -25,22 +25,22 @@ do_bump() { ...@@ -25,22 +25,22 @@ do_bump() {
name=${p%-[0-9]*} name=${p%-[0-9]*}
ver=${p#${name}-} ver=${p#${name}-}
# calculate APKBUILD's path (
set -e
# calculate APKBUILD's path #vim syntax higlight '
if [ "${name#*/}" != "$name" ] && ! [ -d "$APORTSDIR/${name%/*}" ]; then if [ "${name#*/}" != "$name" ] && ! [ -d "$APORTSDIR/${name%/*}" ]; then
error "'$p' should be of form 'foo-1.2.3' or 'main/foo-1.2.3'" die "'$p' should be of form 'foo-1.2.3' or 'main/foo-1.2.3'"
rc=1; continue
fi fi
a=$(aports_buildscript "$name" || die "can't find APKBUILD for $name") || { rc=1; continue; } a=$(aports_buildscript "$name" ) \
|| die "can't find APKBUILD for $name"
# verify APKBUILD # verify APKBUILD
(
. "$a" || exit 1 . "$a" || exit 1
[ "$pkgname" = "$name" ] || die "APKBUILD has different \$pkgname for $name" [ "$pkgname" = "$name" ] \
type package | grep -q function || die "missing package() for $name" || die "APKBUILD has different \$pkgname for $name"
) || { rc=1; continue; } type package | grep -q function \
|| die "missing package() for $name"
(
set -e
cd "${a%/*}" cd "${a%/*}"
section=${PWD%/*} section=${PWD%/*}
...@@ -63,7 +63,8 @@ fixes #${fixes#\#} ...@@ -63,7 +63,8 @@ fixes #${fixes#\#}
git add APKBUILD git add APKBUILD
git commit -m"$message" git commit -m"$message"
) || rc=1 )
rc=$(( $rc + $? ))
done done
return $rc return $rc
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment