[arch-dev-public] [PATCH] parsepkgbuild: don't let test [ return codes leak

Dan McGee dan at archlinux.org
Tue Jun 15 11:14:47 EDT 2010


when using `[ ] && action` style tests, the return code of the test can
leak, which was unfortuante for every PKGBUILD that didn't contain an
install file as the last test would always return 1 (failure). We want
parsepkgbuild to return 0 if we make it all the way through.

"Fix" all of the shortcut test forms to just use the full `if [ ]; then`
block instead of a shortcut.

Signed-off-by: Dan McGee <dan at archlinux.org>
---

Found the problem. I think the commit message covers the jist of it.

-Dan

 parsepkgbuild |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/parsepkgbuild b/parsepkgbuild
index d8bcc98..850fea7 100755
--- a/parsepkgbuild
+++ b/parsepkgbuild
@@ -27,7 +27,9 @@ if [ -n "\$groups" ]; then
 	echo ""
 fi
 
-[ -n "\$url" ] && echo -e "%URL%\n\$url\n"
+if [ -n "\$url" ]; then
+	echo -e "%URL%\n\$url\n"
+fi
 if [ -n "\$license" ]; then
 	echo "%LICENSE%"
 	for i in \${license[@]}; do echo \$i; done
@@ -38,15 +40,21 @@ if [ -n "\$arch" ]; then
 	for i in \${arch[@]}; do echo \$i; done
 	echo ""
 fi
-[ -n "\$builddate" ] && echo -e "%BUILDDATE%\n\$builddate\n"
-[ -n "\$packager" ] && echo -e "%PACKAGER%\n\$packager\n"
+if [ -n "\$builddate" ]; then
+	echo -e "%BUILDDATE%\n\$builddate\n"
+fi
+if [ -n "\$packager" ]; then
+	echo -e "%PACKAGER%\n\$packager\n"
+fi
 
 if [ -n "\$replaces" ]; then
 	echo "%REPLACES%"
 	for i in \${replaces[@]}; do echo \$i; done
 	echo ""
 fi
-[ -n "\$force" ] && echo -e "%FORCE%\n"
+if [ -n "\$force" ]; then
+	echo -e "%FORCE%\n"
+fi
 
 # create depends entry
 if [ -n "\$depends" ]; then
@@ -115,7 +123,8 @@ if [ -n "\$sha512sums" ]; then
 	echo ""
 fi
 
-
-[ -n "\$install" ] && echo -e "%INSTALL%\n\$install\n"
+if [ -n "\$install" ]; then
+	echo -e "%INSTALL%\n\$install\n"
+fi
 
 EOF
-- 
1.7.1



More information about the arch-dev-public mailing list