mirror of https://github.com/asterisk/asterisk
get_sourceable_makeopts wasn't handling variables with embedded double quotes in them very well. One example was the DOWNLOAD variable when curl was being used instead of wget. Rather than trying to fix get_sourceable_makeopts, it's just been removed. ASTERISK-29986 Reported by: Stefan Ruijsenaars Change-Id: Idf2a90902228c2558daa5be7a4f8327556099cd218.12
parent
2d3297d4f3
commit
dd704bbba5
@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
PROGNAME="${0##*/}"
|
||||
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
|
||||
cat <<-EOF
|
||||
Usage: ${PROGNAME}: [ <input_file> ] [ <output_file> ]
|
||||
|
||||
This script takes an Asterisk makeopts file, or any file containing
|
||||
"make" style variable assignments, and converts it into a format
|
||||
that can be directly 'sourced' by shell scripts.
|
||||
|
||||
* Any spaces around the equals sign are removed.
|
||||
* The variable value is quoted.
|
||||
* The "make" "or" command is evaluated.
|
||||
|
||||
Both input and output files are optional and will default to
|
||||
stdin and stdout respectively.
|
||||
|
||||
NOTE: This script relies on NO external commands and only POSIX
|
||||
constructs. It should be runnable by any shell.
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_file="/dev/stdin"
|
||||
if [ "$1" != "" ] ; then
|
||||
input_file="$1"
|
||||
fi
|
||||
|
||||
output_file="/dev/stdout"
|
||||
if [ "$2" != "" ] ; then
|
||||
output_file="$2"
|
||||
fi
|
||||
|
||||
# orfunc is a code fragment to be added to the outp[ut file.
|
||||
# We don't WANT the variables evaluated.
|
||||
# shellcheck disable=SC2016
|
||||
orfunc='or (){ before="${1%,*}" ; after="${1#*,}" ; if [ "$before" = "" ] ; then echo "${after}" ; else echo "${before}" ; fi ; }'
|
||||
echo "${orfunc}" >"${output_file}"
|
||||
|
||||
while read -r LINE ; do
|
||||
var="${LINE%%=*}"
|
||||
if [ "${var}" != "" ] ; then
|
||||
val="${LINE#*=}"
|
||||
if [ "${val}" != "${var}" ] ; then
|
||||
if [ "${val%% *}" = "" ] ; then
|
||||
echo "${var% *}=\"${val#* }\""
|
||||
else
|
||||
echo "${var% *}=\"${val}\""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done <"${input_file}" >>"${output_file}"
|
||||
|
Loading…
Reference in new issue