svn commit: r471991 - head/Mk/Scripts

Devin Teske dteske at FreeBSD.org
Fri Jun 8 15:05:56 UTC 2018


> On Jun 8, 2018, at 5:26 AM, Mathieu Arnold <mat at FreeBSD.org> wrote:
> 
> Author: mat
> Date: Fri Jun  8 09:26:31 2018
> New Revision: 471991
> URL: https://svnweb.freebsd.org/changeset/ports/471991
> 
> Log:
>  SC2015: Note that A && B || C is not if-then-else. C may run when A is true.
> 
>  It's common to use A && B to run B when A is true, and A || C to run C
>  when A is false.
> 
>  However, combining them into A && B || C is not the same as if A then B
>  else C.
> 
>  In this case, if A is true but B is false, C will run.
> 
>  If an if clause is used instead, this problem is avoided.
> 
>  PR:             227109
>  Submitted by:   mat
>  Sponsored by:   Absolight
> 
> Modified:
>  head/Mk/Scripts/qa.sh   (contents, props changed)
> 
> Modified: head/Mk/Scripts/qa.sh
> ==============================================================================
> --- head/Mk/Scripts/qa.sh	Fri Jun  8 09:26:28 2018	(r471990)
> +++ head/Mk/Scripts/qa.sh	Fri Jun  8 09:26:31 2018	(r471991)
> @@ -261,9 +261,10 @@ suidfiles() {
> libtool() {
> 	if [ -z "${USESLIBTOOL}" ]; then
> 		find ${STAGEDIR} -name '*.la' | while read f; do
> -			grep -q 'libtool library' "${f}" &&
> -				err ".la libraries found, port needs USES=libtool" &&
> -				return 1 || true
> +			if grep -q 'libtool library' "${f}"; then
> +				err ".la libraries found, port needs USES=libtool"
> +				return 1
> +			fi
> 		done
> 		# The return above continues here.
> 	fi
> 

Please don't use curlies around the variable name unless you have to slam characters after the expansion (terminating the variable name prematurely for the parser).

When you use curlies like you have above, you're making the parser do more work.

Inside of curlies, it has to parse for 7 additional possibilities aside from the normal valid characters.

It might be thought of as "it just reads until the ending curly" but parameter expansion features of the shell add complexity that is not being addressed here.

If you're not using parameter expansion features (e.g., "${f}") just use "$f"

Here's the ASCII man-page with portions highlighted to show you what the parser has to do when you use $var vs ${var}.



(and if this were bash, there would be even more orange boxes, but we're not talking bash)
-- 
Devin



More information about the svn-ports-all mailing list