diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-12 19:55:00 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-12 19:55:00 (EDT) |
commit | ab9200cc0e1166eeeef7690fa6a67a8d8ce07c5c (patch) | |
tree | e6b70d0eb3f7c89857d55a5ae50832a3f87db183 /lib | |
parent | b14d0b56dd24c705130e76d6f290ee87c1ffe339 (diff) |
ob_parse_control(): Rewrite missing fields handling
Get rid of echo and sed.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/control.sh | 13 |
1 files changed, 7 insertions, 6 deletions
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 |