[pacman-dev] [PATCH 1/1] lint_pkgbuild/pkgname: pkgname is not allowed to be empty
From: Christian Hesse <mail@eworm.de> We checked for empty array elements, but did not catch empty array. Add a check for that case as well. Signed-off-by: Christian Hesse <mail@eworm.de> --- scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in index a044082..2696afa 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in @@ -32,6 +32,11 @@ lint_pkgbuild_functions+=('lint_pkgname') lint_pkgname() { local ret=0 i + if [[ -z "${pkgname[0]}" ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgname" + ret=1 + fi + for i in "${pkgname[@]}"; do if [[ -z $i ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" -- 2.10.0
2016-10-04 10:21 GMT+02:00 Christian Hesse <list@eworm.de>:
From: Christian Hesse <mail@eworm.de>
We checked for empty array elements, but did not catch empty array. Add a check for that case as well.
Signed-off-by: Christian Hesse <mail@eworm.de> --- scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in index a044082..2696afa 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in @@ -32,6 +32,11 @@ lint_pkgbuild_functions+=('lint_pkgname') lint_pkgname() { local ret=0 i
+ if [[ -z "${pkgname[0]}" ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgname" + ret=1 + fi + for i in "${pkgname[@]}"; do if [[ -z $i ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" -- 2.10.0
If pkgname="", this will cause the error message to be printed twice (once in the added if-statement and once in the loop). Should we just return immediately instead of setting ret=1? /Rikard
On 08/10/16 22:11, Rikard Falkeborn wrote:
2016-10-04 10:21 GMT+02:00 Christian Hesse <list@eworm.de>:
From: Christian Hesse <mail@eworm.de>
We checked for empty array elements, but did not catch empty array. Add a check for that case as well.
Signed-off-by: Christian Hesse <mail@eworm.de> --- scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in index a044082..2696afa 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in @@ -32,6 +32,11 @@ lint_pkgbuild_functions+=('lint_pkgname') lint_pkgname() { local ret=0 i
+ if [[ -z "${pkgname[0]}" ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgname" + ret=1 + fi + for i in "${pkgname[@]}"; do if [[ -z $i ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" -- 2.10.0
If pkgname="", this will cause the error message to be printed twice (once in the added if-statement and once in the loop). Should we just return immediately instead of setting ret=1?
Changed the test to: if (( ${#pkgname[@]} == 0 )) ; then then it catches and prints one message for: pkgname= pkgname='' pkgname=() pkgname=('') A
On 09/10/16 23:09, Allan McRae wrote:
On 08/10/16 22:11, Rikard Falkeborn wrote:
2016-10-04 10:21 GMT+02:00 Christian Hesse <list@eworm.de>:
From: Christian Hesse <mail@eworm.de>
We checked for empty array elements, but did not catch empty array. Add a check for that case as well.
Signed-off-by: Christian Hesse <mail@eworm.de> --- scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in index a044082..2696afa 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in @@ -32,6 +32,11 @@ lint_pkgbuild_functions+=('lint_pkgname') lint_pkgname() { local ret=0 i
+ if [[ -z "${pkgname[0]}" ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgname" + ret=1 + fi + for i in "${pkgname[@]}"; do if [[ -z $i ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" -- 2.10.0
If pkgname="", this will cause the error message to be printed twice (once in the added if-statement and once in the loop). Should we just return immediately instead of setting ret=1?
Changed the test to:
if (( ${#pkgname[@]} == 0 )) ; then
then it catches and prints one message for:
pkgname= pkgname='' pkgname=() pkgname=('')
And based on discussion on IRC, further changed to: if [[ -z ${pkgname[@]} ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" return 1 fi This also detects when pkgname is not defined. A
Allan McRae <allan@archlinux.org> on Mon, 2016/10/10 10:32:
On 09/10/16 23:09, Allan McRae wrote:
On 08/10/16 22:11, Rikard Falkeborn wrote:
2016-10-04 10:21 GMT+02:00 Christian Hesse <list@eworm.de>:
From: Christian Hesse <mail@eworm.de>
We checked for empty array elements, but did not catch empty array. Add a check for that case as well.
Signed-off-by: Christian Hesse <mail@eworm.de> --- scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in index a044082..2696afa 100644 --- a/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in +++ b/scripts/libmakepkg/lint_pkgbuild/pkgname.sh.in @@ -32,6 +32,11 @@ lint_pkgbuild_functions+=('lint_pkgname') lint_pkgname() { local ret=0 i
+ if [[ -z "${pkgname[0]}" ]]; then + error "$(gettext "%s is not allowed to be empty.")" "pkgname" + ret=1 + fi + for i in "${pkgname[@]}"; do if [[ -z $i ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" -- 2.10.0
If pkgname="", this will cause the error message to be printed twice (once in the added if-statement and once in the loop). Should we just return immediately instead of setting ret=1?
Changed the test to:
if (( ${#pkgname[@]} == 0 )) ; then
then it catches and prints one message for:
pkgname= pkgname='' pkgname=() pkgname=('')
And based on discussion on IRC, further changed to:
if [[ -z ${pkgname[@]} ]]; then error "$(gettext "%s is not allowed to be empty.")" "pkgname" return 1 fi
This also detects when pkgname is not defined.
That was the case I intended to catch. ;) Figured the problem when reverting a split PKGBUILD to un-split and forgot to change pkgbase to pkgname... Took me some time. Uh... Thanks! -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=0;b=c[a++];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);}
participants (3)
-
Allan McRae
-
Christian Hesse
-
Rikard Falkeborn