From 0e158107ac121c0de7128b8b881a5a54e6f7012e Mon Sep 17 00:00:00 2001 From: olaf michaelis Date: Sat, 5 Aug 2023 03:11:30 +0200 Subject: [PATCH] Fix formal errors in render-readme.sh --- tools/render-readme.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tools/render-readme.sh b/tools/render-readme.sh index 79a783f4..42be4834 100755 --- a/tools/render-readme.sh +++ b/tools/render-readme.sh @@ -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" @@ -17,7 +17,6 @@ ett() { } make_table() { - coutner=0 echo "Generate shared catalog table" ett "\n\n## Shared catalogs" ett "\n|Title|File|" @@ -26,8 +25,7 @@ make_table() { if [[ $(grep -Pc "" "${f}") != 0 ]]; then counter=$((counter + 1)) title=$( - cat "${f}" | - tr '\n' ' ' | + tr '\n' ' ' <"${f}" | grep -Po "" | grep -Po "(?<=title lang=\"en\">).*?(?="${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}"