utils/generate_html_index_srg_mapping.sh
#!/usr/bin/env bash# suppress stdout from pushd and popd commandspushd () { command pushd "$@" > /dev/null} popd references arguments, but none are ever passed.popd () { command popd "$@" > /dev/null} if [ -z "$1" ]; then echo "You must inform a directory to store built files." exit 1fiPAGES_DIR=$1 if [ -z "$2" ]; then echo "You must inform a list of products in double quotes." exit 1fisrg_products=$2 # space separated list of products Double quote to prevent globbing and word splitting.mkdir -p $PAGES_DIR # Generate SRG Mapping TablesDouble quote to prevent globbing and word splitting.pushd $PAGES_DIRtouch index.htmlecho "<!DOCTYPE html>" > index.htmlConsider using { cmd1; cmd2; } >> file instead of individual redirects.echo '<html lang="en">' >> index.htmlecho "<head>" >> index.htmlecho '<meta charset="utf-8" />' >> index.htmlecho "<title>SRG Mapping Tables</title>" >> index.htmlecho "</head>" >> index.htmlecho "<body>" >> index.htmlecho "<h1>SRG Mapping Tables</h1>" >> index.htmlfor product in $srg_productsdoConsider using { cmd1; cmd2; } >> file instead of individual redirects.echo "<h4>Product: ${product}</h4>" >> index.htmlecho "<ul>" >> index.htmlecho "<li><a href=\"srg-mapping-${product}.html\">srg-mapping-${product}.html</a></li>" >> index.htmlecho "<li><a href=\"srg-mapping-${product}.xlsx\">srg-mapping-${product}.xlsx</a></li>" >> index.htmlecho "</ul>" >> index.htmldoneecho "</body>" >> index.htmlecho "</html>" >> index.htmlUse popd "$@" if function's $1 should mean script's $1.popd exit 0