[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH] cvs.eclass: Replace unnecessary eval with bash arrays
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2017-02-22 19:12:45
Message-ID: 20170222191245.22241-1-mgorny () gentoo ! org
[Download RAW message or body]

Replace the eval used to pass quoted password in with simpler and safer
bash arrays. Using eval is strongly discouraged as it is error-prone
and confusing.
---
 eclass/cvs.eclass | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/eclass/cvs.eclass b/eclass/cvs.eclass
index 58efcf1aa2b6..c6e5c66cd866 100644
--- a/eclass/cvs.eclass
+++ b/eclass/cvs.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
@@ -353,22 +353,22 @@ cvs_fetch() {
 	fi
 
 	# Commands to run
-	cmdlogin="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_pass}\" login"
-	cmdupdate="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" update \
                ${ECVS_UP_OPTS} ${ECVS_LOCALNAME}"
-	cmdcheckout="${run} ${ECVS_CVS_COMMAND} -d \"${cvsroot_nopass}\" checkout \
${ECVS_CO_OPTS} ${ECVS_MODULE}" +	cmdlogin=( ${run} ${ECVS_CVS_COMMAND} -d \
"${cvsroot_pass}" login ) +	cmdupdate=( ${run} ${ECVS_CVS_COMMAND} -d \
"${cvsroot_nopass}" update ${ECVS_UP_OPTS} ${ECVS_LOCALNAME} ) +	cmdcheckout=( ${run} \
${ECVS_CVS_COMMAND} -d "${cvsroot_nopass}" checkout ${ECVS_CO_OPTS} ${ECVS_MODULE} )  \
  # Execute commands
 
 	cd "${ECVS_TOP_DIR}"
 	if [[ ${ECVS_AUTH} == "pserver" ]] ; then
-		einfo "Running ${cmdlogin}"
-		eval ${cmdlogin} || die "cvs login command failed"
+		einfo "Running ${cmdlogin[*]}"
+		"${cmdlogin[@]}" || die "cvs login command failed"
 		if [[ ${mode} == "update" ]] ; then
-			einfo "Running ${cmdupdate}"
-			eval ${cmdupdate} || die "cvs update command failed"
+			einfo "Running ${cmdupdate[*]}"
+			"${cmdupdate[@]}" || die "cvs update command failed"
 		elif [[ ${mode} == "checkout" ]] ; then
-			einfo "Running ${cmdcheckout}"
-			eval ${cmdcheckout} || die "cvs checkout command failed"
+			einfo "Running ${cmdcheckout[*]}"
+			"${cmdcheckout[@]}" || die "cvs checkout command failed"
 		fi
 	elif [[ ${ECVS_AUTH} == "ext" || ${ECVS_AUTH} == "no" ]] ; then
 		# Hack to support SSH password authentication
@@ -462,11 +462,11 @@ EOF
 		fi
 
 		if [[ ${mode} == "update" ]] ; then
-			einfo "Running ${cmdupdate}"
-			eval ${cmdupdate} || die "cvs update command failed"
+			einfo "Running ${cmdupdate[*]}"
+			"${cmdupdate[@]}" || die "cvs update command failed"
 		elif [[ ${mode} == "checkout" ]] ; then
-			einfo "Running ${cmdcheckout}"
-			eval ${cmdcheckout} || die "cvs checkout command failed"
+			einfo "Running ${cmdcheckout[*]}"
+			"${cmdcheckout[@]}" || die "cvs checkout command failed"
 		fi
 
 		# Restore environment variable values
-- 
2.11.1


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic