diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-06-24 17:43:20 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-06-24 17:49:41 (EDT) |
commit | 443e4291f8eca1dcafe92cecc897bdb67ca353a0 (patch) | |
tree | 82bd6ba3b6fc5dd54525fc702b588f089e6e4c86 /lib | |
parent | f0efa30ebed5b709fcf60e3ed79d7b5b612bcc90 (diff) |
ob_get_binary_packages(), *ob_*_binary_parameter(): Improve "clean" naming
And fix unbound variables in ob_get_binary_parameter() and
_ob_set_binary_parameter().
Fixes:
FAIL: tests/lib/ob_get_binary_parameter
=======================================
1..5
[...]/lib/libopkbuild.shso.2: line 568: pkg: unbound variable
ok 1 - ob_init_package()
PASS: tests/lib/ob_get_binary_parameter.sh 1 - ob_init_package()
not ok 2 - foo Architecture
FAIL: tests/lib/ob_get_binary_parameter.sh 2 - foo Architecture
# Failed test 'foo Architecture'
# got: ''
[...]/lib/libopkbuild.shso.2: line 568: pkg: unbound variable
# expected: 'any-linux-any'
not ok 3 - foo Platform
FAIL: tests/lib/ob_get_binary_parameter.sh 3 - foo Platform
# Failed test 'foo Platform'
# got: ''
[...]/lib/libopkbuild.shso.2: line 568: pkg: unbound variable
# expected: 'all'
not ok 4 - bar Architecture
FAIL: tests/lib/ob_get_binary_parameter.sh 4 - bar Architecture
# Failed test 'bar Architecture'
# got: ''
[...]/lib/libopkbuild.shso.2: line 568: pkg: unbound variable
# expected: 'all'
not ok 5 - bar Platform
FAIL: tests/lib/ob_get_binary_parameter.sh 5 - bar Platform
# Failed test 'bar Platform'
# got: ''
# expected: 'all'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/package.sh | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/package.sh b/lib/package.sh index 6501ba2..27ea8cb 100644 --- a/lib/package.sh +++ b/lib/package.sh @@ -125,10 +125,8 @@ ob_get_binary_packages() fi # Make sure the "clean" name is unique. - pkg_clean="$({ tr 'a-z' 'A-Z' | tr -dC 'A-Z0-9';} <<-EOF - "${pkg}" - EOF - )" + pkg_clean="$(printf '%s' "${pkg}" | tr 'a-z' 'A-Z' | \ + tr -C 'A-Z0-9' '_')" case "${pkgs_clean}" in *" ${pkg_clean} "*) _ob_warn_msg 'duplicate_clean_binary_name' \ "${pkg_clean}" @@ -211,10 +209,8 @@ ob_get_binary_parameter() fi # Convert package name to its uppercase "clean" form. - package="$({ tr 'a-z' 'A-Z' | tr -dC 'A-Z0-9'; } <<-EOF - "${pkg}" - EOF - )" + package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \ + tr -C 'A-Z0-9' '_')" # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') @@ -323,10 +319,8 @@ _ob_set_binary_parameter() fi # Convert package name to its uppercase "clean" form. - package="$({ tr 'a-z' 'A-Z' | tr -dC 'A-Z0-9'; } <<-EOF - "${pkg}" - EOF - )" + package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \ + tr -C 'A-Z0-9' '_')" # Convert field name to uppercase and validate. case "${name}" in *[!A-Za-z0-9-]* | '') |