From ab9200cc0e1166eeeef7690fa6a67a8d8ce07c5c Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 12 Mar 2019 19:55:00 -0400 Subject: ob_parse_control(): Rewrite missing fields handling Get rid of echo and sed. --- (limited to 'lib/control.sh') diff --git a/lib/control.sh b/lib/control.sh index b99a05c..3bcedbc 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -80,6 +80,7 @@ ob_parse_control() local line= local name= local value= + local sep= if [ ${#} -eq 3 ]; then file="${1}" @@ -173,15 +174,15 @@ ob_parse_control() fi if ${check_fields}; then - req_fields="${req_fields## }" - req_fields="${req_fields%% }" - if [ -n "${req_fields}" ]; then + case "${req_fields}" in *[!\ ]*) # Missing required control fields. - req_fields="$(echo "${req_fields}" | sed 's/ / /g' | \ - sed "s/ /$(ob_get_msg 'list_item_separator')/g")" + sep="$(_ob_get_msg 'list_item_separator')" + req_fields="$(printf "%s${sep}" ${req_fields}; \ + printf 'x')" + req_fields="${req_fields%${sep}x}" _ob_parse_control_error "${file}" '0' \ 'control_missing_fields' "${req_fields}" - fi + esac fi return 0 -- cgit v0.9.1