mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2024-12-18 22:27:51 +00:00
No longer try to use gsed in templater on OSX thanks to .bak workaround
This commit is contained in:
parent
0917b75cb9
commit
d43cecf24a
@ -30,10 +30,6 @@
|
||||
# Copyright (c) 2016 Kevin van Zonneveld (http://kvz.io)
|
||||
|
||||
function templater() {
|
||||
sed=""
|
||||
[ -n "$(which sed)" ] && sed="$(which sed)"
|
||||
[ -n "$(which gsed)" ] && sed="$(which gsed)"
|
||||
|
||||
ALLOW_REMAINDERS="${ALLOW_REMAINDERS:-0}"
|
||||
|
||||
templateSrc="${1:-}"
|
||||
@ -50,14 +46,14 @@ function templater() {
|
||||
|
||||
cp -f "${templateSrc}" "${templateDst}"
|
||||
for var in $(env |awk -F= '{print $1}' |egrep '^[A-Z0-9_]+$'); do
|
||||
${sed} -i.bak -e "s#\${${var}}#${!var}#g" "${templateDst}"
|
||||
sed -i.bak -e "s#\${${var}}#${!var}#g" "${templateDst}"
|
||||
# this .bak dance is done for BSD/GNU portability: http://stackoverflow.com/a/22084103/151666
|
||||
rm -f "${templateDst}.bak"
|
||||
done
|
||||
|
||||
# cat "${templateDst}"
|
||||
|
||||
if grep '${' ${templateDst} && [ "${ALLOW_REMAINDERS}" = "0" ]; then
|
||||
if grep '${' "${templateDst}" && [ "${ALLOW_REMAINDERS}" = "0" ]; then
|
||||
echo "ERROR: Unable to replace the above template vars"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user