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.
This commit is contained in:
Petr Sumbera 2017-05-05 04:31:02 -07:00
Родитель 9b7924d846
Коммит ad4120d507
1 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -10,49 +10,46 @@
set -e set -e
ac_add_options() { ac_add_options() {
local opt for _mozconfig_opt; do
for opt; do case "$_mozconfig_opt" in
case "$opt" in
--target=*) --target=*)
echo "------BEGIN_MK_OPTION" echo "------BEGIN_MK_OPTION"
echo $opt | sed s/--target/CONFIG_GUESS/ echo $_mozconfig_opt | sed s/--target/CONFIG_GUESS/
echo "------END_MK_OPTION" echo "------END_MK_OPTION"
;; ;;
esac esac
echo "------BEGIN_AC_OPTION" echo "------BEGIN_AC_OPTION"
echo $opt echo $_mozconfig_opt
echo "------END_AC_OPTION" echo "------END_AC_OPTION"
done done
} }
ac_add_app_options() { ac_add_app_options() {
local app _mozconfig_app=$1
app=$1
shift shift
echo "------BEGIN_AC_APP_OPTION" echo "------BEGIN_AC_APP_OPTION"
echo $app echo $_mozconfig_app
echo "$*" echo "$*"
echo "------END_AC_APP_OPTION" echo "------END_AC_APP_OPTION"
} }
mk_add_options() { mk_add_options() {
local opt name op value for _mozconfig_opt; do
for opt; do
echo "------BEGIN_MK_OPTION" echo "------BEGIN_MK_OPTION"
echo $opt echo $_mozconfig_opt
# Remove any leading "export" # Remove any leading "export"
opt=${opt#export} opt=${_mozconfig_opt#export}
case "$opt" in case "$_mozconfig_opt" in
*\?=*) op="?=" ;; *\?=*) _mozconfig_op="?=" ;;
*:=*) op=":=" ;; *:=*) _mozconfig_op=":=" ;;
*+=*) op="+=" ;; *+=*) _mozconfig_op="+=" ;;
*=*) op="=" ;; *=*) _mozconfig_op="=" ;;
esac esac
# Remove the operator and the value that follows # Remove the operator and the value that follows
name=${opt%%${op}*} _mozconfig_name=${_mozconfig_opt%%${_mozconfig_op}*}
# Note: $(echo ${name}) strips the variable from any leading and trailing # Note: $(echo ${_mozconfig_name}) strips the variable from any leading and trailing
# whitespaces. # whitespaces.
eval "$(echo ${name})_IS_SET=1" eval "$(echo ${_mozconfig_name})_IS_SET=1"
echo "------END_MK_OPTION" echo "------END_MK_OPTION"
done done
} }