BlackEagle (3): abort and die are serious errors so throw 255 out when cleanup is called without code exit with 0 get_full_version :: remove duplicated epoch check
lib/common.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Signed-off-by: BlackEagle ike.devolder@gmail.com --- lib/common.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/common.sh b/lib/common.sh index cb9db76..206ea01 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -69,8 +69,8 @@ cleanup() { }
abort() { - msg 'Aborting...' - cleanup 0 + error 'Aborting...' + cleanup 255 }
trap_abort() { @@ -80,12 +80,12 @@ trap_abort() {
trap_exit() { trap - EXIT INT QUIT TERM HUP - cleanup + cleanup 0 }
die() { (( $# )) && error "$@" - cleanup 1 + cleanup 255 }
trap 'trap_abort' INT QUIT TERM HUP
Signed-off-by: BlackEagle ike.devolder@gmail.com --- lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 206ea01..3ca1c7e 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -65,7 +65,7 @@ setup_workdir() {
cleanup() { [[ -n $WORKDIR ]] && rm -rf "$WORKDIR" - [[ $1 ]] && exit $1 + [[ ! -z $1 ]] && exit $1 || exit 0 }
abort() {
On 2014-15-02, BlackEagle ike.devolder@gmail.com wrote:
Signed-off-by: BlackEagle ike.devolder@gmail.com
lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 206ea01..3ca1c7e 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -65,7 +65,7 @@ setup_workdir() {
cleanup() { [[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
- [[ $1 ]] && exit $1
- [[ ! -z $1 ]] && exit $1 || exit 0
Why not simply use "echo ${1:-0}" instead?
}
abort() {
1.8.5.5
On 2014-15-02, Sebastian Schwarz seschwar@gmail.com wrote:
Why not simply use "echo ${1:-0}" instead?
s/echo/exit/, of course.
On Sat, Feb 15, 2014 at 06:13:42PM +0100, BlackEagle wrote:
Signed-off-by: BlackEagle ike.devolder@gmail.com
lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 206ea01..3ca1c7e 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -65,7 +65,7 @@ setup_workdir() {
cleanup() { [[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
- [[ $1 ]] && exit $1
- [[ ! -z $1 ]] && exit $1 || exit 0
[[ ! -z $ 1 ]] is like using a double negative. it's exactly the same as the code you replaced. Why not just:
exit ${1:-0}
On Sat, Feb 15, 2014 at 01:12:41PM -0500, Dave Reisner wrote:
On Sat, Feb 15, 2014 at 06:13:42PM +0100, BlackEagle wrote:
Signed-off-by: BlackEagle ike.devolder@gmail.com
lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 206ea01..3ca1c7e 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -65,7 +65,7 @@ setup_workdir() {
cleanup() { [[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
- [[ $1 ]] && exit $1
- [[ ! -z $1 ]] && exit $1 || exit 0
[[ ! -z $ 1 ]] is like using a double negative. it's exactly the same as the code you replaced. Why not just:
exit ${1:-0}
ok that is indeed much simpler
Signed-off-by: BlackEagle ike.devolder@gmail.com --- lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 3ca1c7e..b817683 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -114,7 +114,7 @@ get_full_version() { pkgbase=${pkgbase:-${pkgname[0]}} epoch=${epoch:-0} if [[ -z $1 ]]; then - if [[ $epoch ]] && (( ! $epoch )); then + if (( ! $epoch )); then echo $pkgver-$pkgrel else echo $epoch:$pkgver-$pkgrel
On Sat, Feb 15, 2014 at 06:13:43PM +0100, BlackEagle wrote:
Signed-off-by: BlackEagle ike.devolder@gmail.com
lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 3ca1c7e..b817683 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -114,7 +114,7 @@ get_full_version() { pkgbase=${pkgbase:-${pkgname[0]}} epoch=${epoch:-0} if [[ -z $1 ]]; then
if [[ $epoch ]] && (( ! $epoch )); then
if (( ! $epoch )); then
This will break when epoch isn't defined -- that's why the original string based check is "necessary". It be avoided though, if you write this as:
if (( ! epoch )); then
echo $pkgver-$pkgrel else echo $epoch:$pkgver-$pkgrel
-- 1.8.5.5
On Sat, Feb 15, 2014 at 01:13:41PM -0500, Dave Reisner wrote:
On Sat, Feb 15, 2014 at 06:13:43PM +0100, BlackEagle wrote:
Signed-off-by: BlackEagle ike.devolder@gmail.com
lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 3ca1c7e..b817683 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -114,7 +114,7 @@ get_full_version() { pkgbase=${pkgbase:-${pkgname[0]}} epoch=${epoch:-0} if [[ -z $1 ]]; then
if [[ $epoch ]] && (( ! $epoch )); then
if (( ! $epoch )); then
This will break when epoch isn't defined -- that's why the original string based check is "necessary". It be avoided though, if you write this as:
if (( ! epoch )); then
But epoch is always there: epoch=${ecpoch:-O}
echo $pkgver-$pkgrel else echo $epoch:$pkgver-$pkgrel
-- 1.8.5.5
taken suggestions of the mailinglist into account
BlackEagle (3): abort and die are serious errors so throw 255 out when cleanup is called without code exit with 0 get_full_version :: remove duplicated epoch check
lib/common.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Signed-off-by: BlackEagle ike.devolder@gmail.com --- lib/common.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/common.sh b/lib/common.sh index cb9db76..04a282b 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -69,8 +69,8 @@ cleanup() { }
abort() { - msg 'Aborting...' - cleanup 0 + error 'Aborting...' + cleanup 255 }
trap_abort() { @@ -85,7 +85,7 @@ trap_exit() {
die() { (( $# )) && error "$@" - cleanup 1 + cleanup 255 }
trap 'trap_abort' INT QUIT TERM HUP
Signed-off-by: BlackEagle ike.devolder@gmail.com --- lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 04a282b..1009e90 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -65,7 +65,7 @@ setup_workdir() {
cleanup() { [[ -n $WORKDIR ]] && rm -rf "$WORKDIR" - [[ $1 ]] && exit $1 + exit ${1:-0} }
abort() {
Signed-off-by: BlackEagle ike.devolder@gmail.com --- lib/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common.sh b/lib/common.sh index 1009e90..c9ff1b8 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -114,7 +114,7 @@ get_full_version() { pkgbase=${pkgbase:-${pkgname[0]}} epoch=${epoch:-0} if [[ -z $1 ]]; then - if [[ $epoch ]] && (( ! $epoch )); then + if (( ! epoch )); then echo $pkgver-$pkgrel else echo $epoch:$pkgver-$pkgrel
arch-projects@lists.archlinux.org