Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jun 2018 09:26:20 +0000 (UTC)
From:      Mathieu Arnold <mat@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r471988 - head/Mk/Scripts
Message-ID:  <201806080926.w589QKTX044059@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mat
Date: Fri Jun  8 09:26:20 2018
New Revision: 471988
URL: https://svnweb.freebsd.org/changeset/ports/471988

Log:
  SC2046: Quote this to prevent word splitting.
  
  When command expansions are unquoted, word splitting and globbing will
  occur. This often manifests itself by breaking when filenames contain
  spaces.
  
  Trying to fix it by adding quotes or escapes to the data will not work.
  Instead, quote the command substitution itself.
  
  If the command substitution outputs multiple pieces of data, use a loop
  instead.
  
  Add an exception when using set -- where splitting is intended.
  
  PR:             227109
  Submitted by:   mat
  Exp-run by:	antoine
  Sponsored by:   Absolight

Modified:
  head/Mk/Scripts/check_leftovers.sh   (contents, props changed)
  head/Mk/Scripts/depends-list.sh   (contents, props changed)
  head/Mk/Scripts/find-lib.sh   (contents, props changed)
  head/Mk/Scripts/functions.sh   (contents, props changed)
  head/Mk/Scripts/smart_makepatch.sh   (contents, props changed)

Modified: head/Mk/Scripts/check_leftovers.sh
==============================================================================
--- head/Mk/Scripts/check_leftovers.sh	Fri Jun  8 09:04:27 2018	(r471987)
+++ head/Mk/Scripts/check_leftovers.sh	Fri Jun  8 09:26:20 2018	(r471988)
@@ -45,7 +45,7 @@ fi
 if [ -z "${CCACHE_DIR}" ]; then
 	CCACHE_DIR=$(make -C ${portdir} -VCCACHE_DIR)
 fi
-homedirs=$(awk -F: -v users=$(make -C ${portdir} -V USERS|sed -e 's, ,|,g;/^$/d;s,^,^(,;s,$,)$,') 'users && $1 ~ users {print $9}' ${PORTSDIR}/UIDs|sort -u|sed -e "s|/usr/local|${PREFIX}|"|tr "\n" " ")
+homedirs=$(awk -F: -v users="$(make -C ${portdir} -V USERS|sed -e 's, ,|,g;/^$/d;s,^,^(,;s,$,)$,')" 'users && $1 ~ users {print $9}' ${PORTSDIR}/UIDs|sort -u|sed -e "s|/usr/local|${PREFIX}|"|tr "\n" " ")
 plistsub_sed=$(make -C ${portdir} -VPLIST_SUB_SED | /bin/sh ${PORTSDIR}/Mk/Scripts/plist_sub_sed_sort.sh)
 tmpplist=$(make -C ${portdir} -VTMPPLIST)
 

Modified: head/Mk/Scripts/depends-list.sh
==============================================================================
--- head/Mk/Scripts/depends-list.sh	Fri Jun  8 09:04:27 2018	(r471987)
+++ head/Mk/Scripts/depends-list.sh	Fri Jun  8 09:26:20 2018	(r471988)
@@ -101,10 +101,14 @@ check_dep() {
 		# Grab any needed vars from the port.
 
 		if [ ${requires_wrkdir} -eq 1 ]; then
+			# shellcheck disable=SC2046
+			# We want word splitting here.
 			set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS)
 			wrkdir="$1"
 			shift
 		elif [ ${recursive} -eq 1 ]; then
+			# shellcheck disable=SC2046
+			# We want word splitting here.
 			set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS)
 		fi
 

Modified: head/Mk/Scripts/find-lib.sh
==============================================================================
--- head/Mk/Scripts/find-lib.sh	Fri Jun  8 09:04:27 2018	(r471987)
+++ head/Mk/Scripts/find-lib.sh	Fri Jun  8 09:26:20 2018	(r471988)
@@ -27,7 +27,7 @@ dirs="${LIB_DIRS} $(cat ${LOCALBASE}/libdata/ldconfig/
 for libdir in ${dirs} ; do
 	test -f ${libdir}/${lib} || continue
 	libfile=${libdir}/${lib}
-	[ $(file -b -L --mime-type ${libfile}) = "application/x-sharedlib" ] || continue
+	[ "$(file -b -L --mime-type ${libfile})" = "application/x-sharedlib" ] || continue
 	echo $libfile
 	break
 done

Modified: head/Mk/Scripts/functions.sh
==============================================================================
--- head/Mk/Scripts/functions.sh	Fri Jun  8 09:04:27 2018	(r471987)
+++ head/Mk/Scripts/functions.sh	Fri Jun  8 09:26:20 2018	(r471988)
@@ -188,8 +188,8 @@ export_ports_env() {
 	done
 
 	# Bring in all the vars, but not empty ones.
-	eval $(${MAKE} -f ${PORTSDIR}/Mk/bsd.port.mk ${make_cmd} \
-	    USES="${uses}" | grep -v '=$' | sed -e 's,\\ $,,')
+	eval "$(${MAKE} -f ${PORTSDIR}/Mk/bsd.port.mk ${make_cmd} \
+		USES="${uses}" | grep -v '=$' | sed -e 's,\\ $,,')"
 	for var in ${export_vars}; do
 		# Export and display non-empty ones.  This is not redundant
 		# with above since we're looping on all vars here; do not

Modified: head/Mk/Scripts/smart_makepatch.sh
==============================================================================
--- head/Mk/Scripts/smart_makepatch.sh	Fri Jun  8 09:04:27 2018	(r471987)
+++ head/Mk/Scripts/smart_makepatch.sh	Fri Jun  8 09:26:20 2018	(r471988)
@@ -63,7 +63,7 @@ std_patch_filename() {
 	local raw_name
 	sans_cwd=$(echo $1 | sed 's|^\.\/||')
 	raw_name=$(strip_path ${sans_cwd})
-	echo patch-$(echo ${raw_name} | sed -e 's|_|&&|g; s|/|_|g')
+	echo "patch-$(echo ${raw_name} | sed -e 's|_|&&|g; s|/|_|g')"
 }
 
 patchdir_files_list() {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806080926.w589QKTX044059>