Date: Tue, 23 Jan 2018 15:53:56 +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: r459782 - head/Tools/scripts Message-ID: <201801231553.w0NFruOs029748@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mat Date: Tue Jan 23 15:53:56 2018 New Revision: 459782 URL: https://svnweb.freebsd.org/changeset/ports/459782 Log: Run Tools/scripts/mfh through devel/hs-ShellCheck. SC2068: Double quote array expansions to avoid re-splitting elements. SC2034: revs appears unused. Verify it or export it. SC2039: In POSIX sh, XXX is undefined. type -> command -v echo -n -> printf read -p -> printf + read SC2162: read without -r will mangle backslashes. SC2086: Double quote to prevent globbing and word splitting. Sponsored by: Absolight Modified: head/Tools/scripts/mfh Modified: head/Tools/scripts/mfh ============================================================================== --- head/Tools/scripts/mfh Tue Jan 23 15:52:45 2018 (r459781) +++ head/Tools/scripts/mfh Tue Jan 23 15:53:56 2018 (r459782) @@ -54,18 +54,19 @@ ask() { answer=x while [ "${answer}" != "y" -a "${answer}" != "n" ] ; do - read -p "${question} [y/n] " answer + printf "%s [y/n] " "${question}" + read -r answer done [ "${answer}" = "y" ] && return 0 return 1 } -: ${svnserver:="svn+ssh://repo.FreeBSD.org"} +: "${svnserver:="svn+ssh://repo.FreeBSD.org"}" -if [ -n "$(type svn 2>/dev/null)" ]; then +if [ -n "$(command -v svn 2>/dev/null)" ]; then svn=svn -elif [ -n "$(type svnlite 2>/dev/null)" ]; then +elif [ -n "$(command -v svnlite 2>/dev/null)" ]; then svn=svnlite else err "Neither svn(1) nor svnlite(1) found. Please install devel/subversion." @@ -73,21 +74,20 @@ fi latest_branch=$("${svn}" ls ${svnserver}/ports/branches/|sed -ne '/^2.*Q./s|/$||p'|tail -1) -[ $# -lt 1 ] && err "$(basename $0) requires at least 1 arguments: [<branch>] <revnumber> [<revnumber>...]" +[ $# -lt 1 ] && err "$(basename "$0") requires at least 1 arguments: [<branch>] <revnumber> [<revnumber>...]" branch=$1 # I sure hope by 2030 we'll be doing something else. Yes, famous last words. -if expr ${branch} : '20[12][0-9]Q[1-4]' > /dev/null; then +if expr "${branch}" : '20[12][0-9]Q[1-4]' > /dev/null; then shift - if [ ${latest_branch} != ${branch} ]; then + if [ "${latest_branch}" != "${branch}" ]; then ask "/!\\ The latest branch is ${latest_branch}, do you really want to commit to ${branch}?" || exit 1 fi else branch=${latest_branch} fi -revs="" -for rev in $@ +for rev in "$@" do rev=${rev##r} # remove a leading "r" case ${rev} in @@ -102,17 +102,17 @@ cd "${dir}" "${svn}" co --depth=empty ${svnserver}/ports/branches/"${branch}" filelist="" -echo -n "MFH:" > commit.txt -for rev in $@ +printf "MFH:" > commit.txt +for rev in "$@" do rev=${rev##r} - echo -n " r${rev}" >> commit.txt + printf " r%s" "${rev}" >> commit.txt done echo >> commit.txt -for rev in $@ +for rev in "$@" do rev=${rev##r} - for f in $("${svn}" diff --summarize -c r${rev} ${svnserver}/ports/head); do + for f in $("${svn}" diff --summarize -c "r${rev}" "${svnserver}/ports/head"); do case ${f} in */*) ;; *)continue;; @@ -121,17 +121,17 @@ do f=${f%/*} filelist="${filelist}${LF}${f}" done - "${svn}" log -r${rev##-} ${svnserver}/ports/head | sed '1,2d;$d;/^MFH:/d' \ + "${svn}" log "-r${rev##-}" ${svnserver}/ports/head | sed '1,2d;$d;/^MFH:/d' \ | sed '$d' >> commit.txt done filelist=$(printf '%s\n' "${filelist}" | sort -u) "${svn}" up --parents $(printf '%s\n' $filelist \ | sed "s}^}${branch}/}") "${svn}" up --quiet "${branch}" -for rev in $@ +for rev in "$@" do rev=${rev##r} - "${svn}" merge -c r${rev} ^/head/ "${branch}" + "${svn}" merge -c "r${rev}" ^/head/ "${branch}" done "${svn}" up --quiet "${branch}" "${svn}" status "${branch}"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801231553.w0NFruOs029748>