summaryrefslogtreecommitdiffstats
path: root/lib/control.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/control.sh')
-rw-r--r--lib/control.sh51
1 files changed, 31 insertions, 20 deletions
diff --git a/lib/control.sh b/lib/control.sh
index 0e9a1f6..12dc8bd 100644
--- a/lib/control.sh
+++ b/lib/control.sh
@@ -32,17 +32,22 @@ ob_parse_control()
_obpco_all_fields _obpco_got_fields \
_obpco_line_nr _obpco_line _obpco_name _obpco_value
- if [ ${#} -eq 4 ]; then
+ if [ ${#} -eq 2 ]; then
+ _obpco_file="${1}"
+ _obpco_field_cb="${2}"
+ _obpco_check_fields='false'
+ elif [ ${#} -eq 4 ]; then
_obpco_file="${1}"
_obpco_field_cb="${2}"
_obpco_req_fields="${3}"
_obpco_opt_fields="${4}"
+ _obpco_check_fields='true'
+ _obpco_all_fields=" ${_obpco_req_fields} ${_obpco_opt_fields} "
else
_ob_return 125
return ${?}
fi
- _obpco_all_fields=" ${_obpco_req_fields} ${_obpco_opt_fields} "
_obpco_got_fields=' '
_obpco_line_nr=0
@@ -72,15 +77,18 @@ ob_parse_control()
'control_bad_nv'
continue
fi
- if [ "${_obpco_all_fields% ${_obpco_name} *}" = \
- "${_obpco_all_fields}" ]; then
- # Unknown field.
- _ob_parse_control_error "${_obpco_file}" "${_obpco_line_nr}" \
- 'control_unknown_field' "${_obpco_name}"
- else
- # Remove field from list of required fields.
- _obpco_req_fields="$(echo "${_obpco_req_fields}" | \
- sed "s/${_obpco_name}//")"
+ if ${_obpco_check_fields}; then
+ if [ "${_obpco_all_fields% ${_obpco_name} *}" = \
+ "${_obpco_all_fields}" ]; then
+ # Unknown field.
+ _ob_parse_control_error \
+ "${_obpco_file}" "${_obpco_line_nr}" \
+ 'control_unknown_field' "${_obpco_name}"
+ else
+ # Remove field from list of required fields.
+ _obpco_req_fields="$(echo "${_obpco_req_fields}" | \
+ sed "s/${_obpco_name}//")"
+ fi
fi
if [ "${_obpco_got_fields% ${_obpco_name} *}" != \
"${_obpco_got_fields}" ]; then
@@ -113,15 +121,18 @@ ${_obpco_line# }"
fi
fi
- _obpco_req_fields="${_obpco_req_fields## }"
- _obpco_req_fields="${_obpco_req_fields%% }"
- if [ -n "${_obpco_req_fields}" ]; then
- # Missing required control fields.
- _obpco_req_fields="$(echo "${_obpco_req_fields}" | sed 's/ / /g' | \
- sed "s/ /$(ob_get_msg 'list_item_separator')/g")"
- _ob_parse_control_error "${_obpco_file}" '0' \
- 'control_missing_fields' \
- "${_obpco_req_fields}"
+ if ${_obpco_check_fields}; then
+ _obpco_req_fields="${_obpco_req_fields## }"
+ _obpco_req_fields="${_obpco_req_fields%% }"
+ if [ -n "${_obpco_req_fields}" ]; then
+ # Missing required control fields.
+ _obpco_req_fields="$(echo "${_obpco_req_fields}" | \
+ sed 's/ / /g' | \
+ sed "s/ /$(ob_get_msg 'list_item_separator')/g")"
+ _ob_parse_control_error "${_obpco_file}" '0' \
+ 'control_missing_fields' \
+ "${_obpco_req_fields}"
+ fi
fi
_ob_return 0