1 |
commit: d03e5fcf3b23d33d240acc356c3d5bd1f009d047 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 3 01:23:45 2021 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 3 01:23:45 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/build-docbook-catalog.git/commit/?id=d03e5fcf |
7 |
|
8 |
switch to arrays |
9 |
|
10 |
The files we work with are supposed to be simple so this shouldn't |
11 |
super matter, but now that newer bash and tools have options to |
12 |
easily work with these, might as well switch over to fix quoting. |
13 |
|
14 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
15 |
|
16 |
build-docbook-catalog | 33 +++++++++++++++++---------------- |
17 |
1 file changed, 17 insertions(+), 16 deletions(-) |
18 |
|
19 |
diff --git a/build-docbook-catalog b/build-docbook-catalog |
20 |
index 0ecbc1c..b815bfc 100755 |
21 |
--- a/build-docbook-catalog |
22 |
+++ b/build-docbook-catalog |
23 |
@@ -14,7 +14,8 @@ ROOTCONFDIR="${EPREFIX}"/etc/xml |
24 |
ROOTCATALOG=${ROOTCONFDIR}/catalog |
25 |
CATALOG=${ROOTCONFDIR}/docbook |
26 |
DOCBOOKDIR="${EPREFIX}"/usr/share/sgml/docbook |
27 |
-DTDS= |
28 |
+DTDS=() |
29 |
+SIMPLE_DTDS=() |
30 |
LATEST_DTD= |
31 |
LATEST_DATE= |
32 |
VERBOSE=false |
33 |
@@ -56,7 +57,7 @@ main() { |
34 |
shift |
35 |
done |
36 |
|
37 |
- : ${ROOT:=/} |
38 |
+ : "${ROOT:=/}" |
39 |
[[ ${ROOT} != */ ]] && ROOT="${ROOT}/" |
40 |
[[ ${ROOT} != /* ]] && ROOT="${PWD}${ROOT}" |
41 |
if [[ ${ROOT} != "/" ]] ; then |
42 |
@@ -88,11 +89,11 @@ main() { |
43 |
clean_catalog "${DOCBOOKDIR}/xml\(-simple\)*-dtd-[^/\"']*/[^/\"']*" "${ROOTCATALOG}" |
44 |
|
45 |
if set_dtds; then |
46 |
- for d in ${DTDS}; do |
47 |
- populate_dtd ${d} |
48 |
+ for d in "${DTDS[@]}"; do |
49 |
+ populate_dtd "${d}" |
50 |
done |
51 |
- for d in ${SIMPLE_DTDS}; do |
52 |
- populate_simple_dtd ${d} |
53 |
+ for d in "${SIMPLE_DTDS[@]}"; do |
54 |
+ populate_simple_dtd "${d}" |
55 |
done |
56 |
populate_entities |
57 |
fi |
58 |
@@ -122,17 +123,17 @@ error() { |
59 |
# fill in the DTDS variable based on installed versions |
60 |
# |
61 |
set_dtds() { |
62 |
- DTDS= SIMPLE_DTS= |
63 |
+ DTDS=() SIMPLE_DTDS=() |
64 |
|
65 |
local d=${ROOT}${DOCBOOKDIR} |
66 |
if [[ -d ${d} ]] ; then |
67 |
pushd "${d}" >/dev/null || return 1 |
68 |
- DTDS=$(find xml-dtd-*/ -name docbookx.dtd) |
69 |
- SIMPLE_DTDS=$(find xml-simple-dtd-*/ -name sdocbook.dtd) |
70 |
- popd >/dev/null |
71 |
+ mapfile -d $'\0' DTDS < <(find xml-dtd-*/ -name docbookx.dtd -print0) |
72 |
+ mapfile -d $'\0' SIMPLE_DTDS < <(find xml-simple-dtd-*/ -name sdocbook.dtd -print0) |
73 |
+ popd >/dev/null || return 1 |
74 |
fi |
75 |
|
76 |
- if [[ -z ${DTDS} ]]; then |
77 |
+ if [[ ${#DTDS[@]} -eq 0 ]]; then |
78 |
echo "No installed DocBook XML DTDs found" |
79 |
return 1 |
80 |
else |
81 |
@@ -346,10 +347,10 @@ populate_entities() { |
82 |
) |
83 |
|
84 |
# here are the entities available; assume no spaces in filenames... |
85 |
- avail=($(ls "${ROOT}${isodir}" | sort)) |
86 |
+ mapfile -d $'\0' avail < <(find "${ROOT}${isodir}" -maxdepth 1 -type f -printf '%f\0' | sort -z) |
87 |
|
88 |
# double-check the lists |
89 |
- verb " Populating ${CATALOG} with ISO DocBook entities" |
90 |
+ verb " Populating ${CATALOG} with ${#avail[@]} ISO DocBook entities" |
91 |
i=0 ; j=0 |
92 |
while [[ ${i} -lt ${#entities[@]} || ${j} -lt ${#avail[@]} ]]; do |
93 |
if [[ ${i} -ge ${#entities[@]} ]]; then |
94 |
@@ -358,13 +359,13 @@ populate_entities() { |
95 |
elif [[ ${j} -ge ${#avail[@]} ]]; then |
96 |
echo "Warning: Entities file not found: ${entities[i]}" |
97 |
: $(( i += 2 )) |
98 |
- elif [[ ${avail[j]} < ${entities[i]} ]]; then |
99 |
+ elif [[ ${avail[j]} < "${entities[i]}" ]]; then |
100 |
echo "Warning: Extra ISO entities file: ${avail[j]}" |
101 |
: $(( j += 1 )) |
102 |
- elif [[ ${entities[i]} < ${avail[j]} ]]; then |
103 |
+ elif [[ ${entities[i]} < "${avail[j]}" ]]; then |
104 |
echo "Warning: Entities file not found: ${entities[i]}" |
105 |
: $(( i += 2 )) |
106 |
- elif [[ ${entities[i]} == ${avail[j]} ]]; then |
107 |
+ elif [[ ${entities[i]} == "${avail[j]}" ]]; then |
108 |
xmlcatalog --noout --add "public" "${entities[i+1]}" \ |
109 |
"file://${isodir}/${entities[i]}" "${ROOT}${CATALOG}" |
110 |
: $(( j += 1 )) |