refactor: improve template handler on shell expansions
This commit is contained in:
parent
3594d15c5c
commit
1e4740a08f
@ -52,14 +52,6 @@ log() {
|
||||
# Yes
|
||||
#
|
||||
|
||||
# Set debug status depending if a global debug variable has been set to either 1 or 0
|
||||
local debug
|
||||
if [ ${DEBUG} ]; then
|
||||
debug=${DEBUG}
|
||||
else
|
||||
debug=0
|
||||
fi
|
||||
|
||||
local FORMAT
|
||||
FORMAT="[$(echo_rgb "$(date +%Y-%m-%dT%H:%M:%S)" 180 140 255)]"
|
||||
|
||||
@ -166,7 +158,7 @@ _write_to_buffer() {
|
||||
var_handler() {
|
||||
local variable="${1}"
|
||||
local leading_spaces="${2}"
|
||||
while IFS="\n" read -r line; do
|
||||
while IFS=$'\n' read -r line; do
|
||||
write_content "${line}" "${leading_spaces}"
|
||||
done <<<"${variable}"
|
||||
}
|
||||
@ -174,7 +166,7 @@ var_handler() {
|
||||
eval_handler() {
|
||||
local eval_statement="${1}"
|
||||
local leading_spaces="${2}"
|
||||
while IFS="\n" read -r line; do
|
||||
while IFS=$'\n' read -r line; do
|
||||
write_content "${line}" "${leading_spaces}"
|
||||
done <<<"$(eval "${eval_statement}")"
|
||||
}
|
||||
@ -215,7 +207,7 @@ file_handler() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
while IFS="\n" read -r line; do
|
||||
while IFS=$'\n' read -r line; do
|
||||
write_content "${line}" "${leading_spaces}"
|
||||
done <"${file}"
|
||||
}
|
||||
@ -330,7 +322,7 @@ read_template() {
|
||||
line_num=1
|
||||
read_file="${1}"
|
||||
log "info" "Parsing template file \"${read_file}\""
|
||||
while IFS="\n" read -r line; do
|
||||
while IFS=$'\n' read -r line; do
|
||||
# Check for non zero status code
|
||||
if ! parse_template_line "${line}"; then
|
||||
log "error" "Invalid template passed from \"${read_file}\", check line ${line_num}"
|
||||
@ -389,7 +381,7 @@ usage() {
|
||||
# Yes
|
||||
#
|
||||
printf "Usage: %s\n" \
|
||||
"$(basename ${0}) [OPTIONS]
|
||||
"$(basename "${0}") [OPTIONS]
|
||||
$(arg_required "REQUIRED")
|
||||
$(arg_optional "OPTIONAL")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user