Bug 1360571 - Remove "local" bashism from mozconfig_loader. r=glandium
authorPetr Sumbera <petr.sumbera@oracle.com>
Fri, 05 May 2017 04:31:02 -0700
changeset 357344 6baa8102c70d55ad18c93728f270663ad6513d77
parent 357343 e69c902071600ff38c287b8891435251807cd637
child 357345 f1f27357f20825726229712eeea15d6d629ecabd
push id31789
push userkwierso@gmail.com
push dateTue, 09 May 2017 21:36:07 +0000
treeherdermozilla-central@120d8562d4a5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1360571
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1360571 - Remove "local" bashism from mozconfig_loader. r=glandium mozconfig_loader is invoked with /bin/sh, which may not be bash. We could force mozconfigs to be run with bash instead, but that might be disruptive for existing mozconfigs, and the sole bashism used in mozconfig_loader is rather straightforward to workaround by namespacing the variables.
python/mozbuild/mozbuild/mozconfig_loader
--- a/python/mozbuild/mozbuild/mozconfig_loader
+++ b/python/mozbuild/mozbuild/mozconfig_loader
@@ -5,59 +5,56 @@
 
 # This script provides an execution environment for mozconfig scripts.
 # This script is not meant to be called by users. Instead, some
 # higher-level driver invokes it and parses the machine-tailored output.
 
 set -e
 
 ac_add_options() {
-  local opt
-  for opt; do
-    case "$opt" in
+  for _mozconfig_opt; do
+    case "$_mozconfig_opt" in
     --target=*)
       echo "------BEGIN_MK_OPTION"
-      echo $opt | sed s/--target/CONFIG_GUESS/
+      echo $_mozconfig_opt | sed s/--target/CONFIG_GUESS/
       echo "------END_MK_OPTION"
       ;;
     esac
     echo "------BEGIN_AC_OPTION"
-    echo $opt
+    echo $_mozconfig_opt
     echo "------END_AC_OPTION"
   done
 }
 
 ac_add_app_options() {
-  local app
-  app=$1
+  _mozconfig_app=$1
   shift
   echo "------BEGIN_AC_APP_OPTION"
-  echo $app
+  echo $_mozconfig_app
   echo "$*"
   echo "------END_AC_APP_OPTION"
 }
 
 mk_add_options() {
-  local opt name op value
-  for opt; do
+  for _mozconfig_opt; do
     echo "------BEGIN_MK_OPTION"
-    echo $opt
+    echo $_mozconfig_opt
     # Remove any leading "export"
-    opt=${opt#export}
-    case "$opt" in
-    *\?=*) op="?=" ;;
-    *:=*) op=":=" ;;
-    *+=*) op="+=" ;;
-    *=*) op="=" ;;
+    opt=${_mozconfig_opt#export}
+    case "$_mozconfig_opt" in
+    *\?=*) _mozconfig_op="?=" ;;
+    *:=*) _mozconfig_op=":=" ;;
+    *+=*) _mozconfig_op="+=" ;;
+    *=*) _mozconfig_op="=" ;;
     esac
     # Remove the operator and the value that follows
-    name=${opt%%${op}*}
-    # Note: $(echo ${name}) strips the variable from any leading and trailing
+    _mozconfig_name=${_mozconfig_opt%%${_mozconfig_op}*}
+    # Note: $(echo ${_mozconfig_name}) strips the variable from any leading and trailing
     # whitespaces.
-    eval "$(echo ${name})_IS_SET=1"
+    eval "$(echo ${_mozconfig_name})_IS_SET=1"
     echo "------END_MK_OPTION"
   done
 }
 
 echo "------BEGIN_ENV_BEFORE_SOURCE"
 $3 $4
 echo "------END_ENV_BEFORE_SOURCE"