[arch-projects] [devtools] [PATCH 0/3] small enhancements
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(-) -- 1.8.5.5
Signed-off-by: BlackEagle
Signed-off-by: BlackEagle
On 2014-15-02, BlackEagle
Signed-off-by: BlackEagle
--- 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
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
--- 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
--- 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 -- Ike
Signed-off-by: BlackEagle
On Sat, Feb 15, 2014 at 06:13:43PM +0100, BlackEagle wrote:
Signed-off-by: BlackEagle
--- 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
--- 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
-- Ike
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(-) -- 1.8.5.5
Signed-off-by: BlackEagle
Signed-off-by: BlackEagle
Signed-off-by: BlackEagle
participants (4)
-
BlackEagle
-
Dave Reisner
-
Ike Devolder
-
Sebastian Schwarz