Skip to content

Commit

Permalink
Fix formal errors in render-readme.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
triole committed Aug 5, 2023
1 parent e41f001 commit 0e15810
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tools/render-readme.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
basedir=$(echo "${scriptdir}" | grep -Po ".*(?=\/)")
arr=($(find "${basedir}/shared" -regex ".*\.xml$" | sort))
mapfile -t arr < <(find "${basedir}/shared" -regex ".*\.xml$" | sort)

placeholder="___NEW_TABLE___"
readme_file="${basedir}/README.md"
Expand All @@ -17,7 +17,6 @@ ett() {
}

make_table() {
coutner=0
echo "Generate shared catalog table"
ett "\n\n## Shared catalogs"
ett "\n|Title|File|"
Expand All @@ -26,8 +25,7 @@ make_table() {
if [[ $(grep -Pc "<catalog\sdc:uri=.*>" "${f}") != 0 ]]; then
counter=$((counter + 1))
title=$(
cat "${f}" |
tr '\n' ' ' |
tr '\n' ' ' <"${f}" |
grep -Po "<catalog\s.*<\/catalog>" |
grep -Po "(?<=title lang=\"en\">).*?(?=</title)"
)
Expand All @@ -39,18 +37,18 @@ make_table() {
ett "\n${counter} catalogs shared\n"
}

function remove_old_table() {
remove_old_table() {
echo "Remove old table"
sed -ze "s/## Shared catalogs[^<]*catalogs shared/${placeholder}/g" \
"${readme_file}" >"${temp_readme}"
}

function insert_new_table() {
insert_new_table() {
echo "Insert new table"
sed -i "/${placeholder}/r ${temp_table}" "${temp_readme}"
}

function clean_up() {
clean_up() {
echo "Clean up README.md"
sed -i "s/${placeholder}//g" "${temp_readme}"
cat -s "${temp_readme}" >"${readme_file}"
Expand Down

0 comments on commit 0e15810

Please sign in to comment.