[pacman-dev] [PATCH] Fix the implementation of lint_variable.

Allan McRae allan at archlinux.org
Thu Nov 12 09:28:45 UTC 2015


On 12/11/15 19:18, Allan McRae wrote:
> On 12/11/15 18:37, David Grayson wrote:
>> The old implementation had both false negatives and false positives.
>>
>> Because of the -w option to grep, it didn't detect lines like:
>>
>>   license=bad
>>
>> Additionally, it did detect irrelevant lines like this:
>>
>>   --with-arch=${_arch}
>>
>> The latter is a false positive which made it difficult to build valid
>> packages.
>>
> 
> This does not catch bad variables in the package() arrays.
> 

Try this:


diff --git a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
index 1daac26..412da25 100644
--- a/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
+++ b/scripts/libmakepkg/lint_pkgbuild/variable.sh.in
@@ -39,7 +39,7 @@ lint_variable() {

 	local i
 	for i in ${array[@]}; do
-		if grep -w -q -e "$i=[^(]" -e "$i+=[^(]" "$BUILDSCRIPT"; then
+		if grep -q -e "^[[:space:]]*$i=[^(]" -e "^[[:space:]]*$i+=[^(]"
"$BUILDSCRIPT"; then
 			error "$(gettext "%s should be an array")" "$i"
 			ret=1
 		fi
@@ -49,7 +49,7 @@ lint_variable() {
 		[[ $a == "any" ]] && continue

 		for i in ${arch_array[@]}; do
-			if grep -w -q -e "$i_$a=[^(]" -e "$i_$a+=[^(]" "$BUILDSCRIPT"; then
+			if grep -q -e "^[[:space:]]*$i_$a=[^(]" -e
"^[[:space:]]*$i_$a+=[^(]" "$BUILDSCRIPT"; then
 				error "$(gettext "%s_%s should be an array")" "$i" "$a"
 				ret=1
 			fi
@@ -57,7 +57,7 @@ lint_variable() {
 	done

 	for i in ${string[@]}; do
-		if grep -w -q -e "$i=(" -e "$i+=(" "$BUILDSCRIPT"; then
+		if grep -q -e "^[[:space:]]*$i=(" -e "^^[[:space:]]*$i+=("
"$BUILDSCRIPT"; then
 			error "$(gettext "%s should not be an array")" "$i"
 			ret=1
 		fi


More information about the pacman-dev mailing list