diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-13 01:10:47 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-13 01:10:47 (EDT) |
commit | 5e69b33c9e2cc711314057385777b93fbaf4d52f (patch) | |
tree | 3470469ee3fa1f551d57cfcc7b29a4c1463cad7f | |
parent | 84cf2433571977ad129335960647557552d9d549 (diff) |
ob_match_arch(): Replace generated ERE with native SCL
-rw-r--r-- | lib/metadata.sh | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/metadata.sh b/lib/metadata.sh index 8ce838d..c2aec99 100644 --- a/lib/metadata.sh +++ b/lib/metadata.sh @@ -188,7 +188,10 @@ ob_match_arch() local arch= local arch_field= local a= - local a_ere= + local match_arch_rest= + local field_arch_rest= + local match_arch_part= + local field_arch_part= if [ ${#} -eq 2 ]; then arch="${1}" @@ -213,14 +216,23 @@ ob_match_arch() return 0 fi - # Generate an ERE to match hyphenated architectures. - a_ere="$(echo "${a}" | \ - sed 's/^any-/[^-]+-/;s/-any-/-[^-]+-/g;s/-any$/-[^-]+/g')" - # "foo-bar-baz" == "foo-any-any" - if echo "${arch}" | grep -E "${a_ere}" >/dev/null 2>&1; then - return 0 - fi + match_arch_rest="${arch}" + field_arch_rest="${a}" + while [ -n "${match_arch_rest}" ] && [ -n "${field_arch_rest}" ] + do + IFS='-' read match_arch_part match_arch_rest <<-EOF + ${match_arch_rest} + EOF + IFS='-' read field_arch_part field_arch_rest <<-EOF + ${field_arch_rest} + EOF + case "${field_arch_part}" in + "${match_arch_part}" | 'any') ;; + *) continue 2;; # Failed match, go to next arch + esac + done + return 0 done |