From a2267f9838b661d4cf75019d6301ab2627524af6 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Tue, 23 Apr 2019 17:26:50 -0400 Subject: parse_control(): Convert to [ -n and -z operators --- (limited to 'src/control.sh') diff --git a/src/control.sh b/src/control.sh index 2a7634d..04a4c2d 100644 --- a/src/control.sh +++ b/src/control.sh @@ -64,7 +64,7 @@ parse_control() # initialization code (see heredocument # below). in_paragraph='false' - if [ "x${name}" != 'x' ]; then + if [ -n "${name}" ]; then if ! "${field_cb}" "${name}" \ "${value}"; then return 0 @@ -73,7 +73,7 @@ parse_control() if ! "${paragraph_cb}"; then return 0 fi - if [ "x${para_req_fields}" != 'x' ]; then + if [ -n "${para_req_fields}" ]; then para_req_fields="$(printf \ "%s$(get_msg \ 'list_item_separator')"\ @@ -94,7 +94,7 @@ parse_control() ;; [!\ ]*':'*) # "Name: Value" line. in_paragraph='true' - if [ "x${name}" != 'x' ]; then + if [ -n "${name}" ]; then if ! "${field_cb}" "${name}" "${value}" then return 0 @@ -103,12 +103,12 @@ parse_control() IFS=': ' read name value <<-EOF ${line} EOF - if [ "x${name}" = 'x' ]; then + if [ -z "${name}" ]; then _parse_control_error "${file}" \ "${line_nr}" 'control_bad_nv' continue fi - if [ "x${para_req_fields}" != 'x' ]; then + if [ -n "${para_req_fields}" ]; then # Remove field from list of required # fields. para_req_fields="$(printf '%s' \ @@ -128,7 +128,7 @@ parse_control() ;; ' '*) # Continuation line. in_paragraph='true' - if [ "x${name}" = 'x' ]; then + if [ -z "${name}" ]; then # Expecting a "Name: Value" line. _parse_control_error "${file}" \ "${line_nr}" \ @@ -148,7 +148,7 @@ parse_control() # The second blank line above is needed because the command substitution # removes any trailing newlines. - if [ "x${name}" != 'x' ]; then + if [ -n "${name}" ]; then if ! "${field_cb}" "${name}" "${value}"; then return 0 fi -- cgit v0.9.1