From bf4a390c23a860ff8bda9538942f2b16cdcf8c05 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 4 Apr 2023 12:10:54 -0300 Subject: Makefile: Add ShellCheck to "check" target --- v2/aux/checks/shellcheck.sh | 6 +++ v2/dynamic.mk | 13 +++++- v2/src/bin/makemake | 5 ++- v2/src/development/genhtml.sh | 93 ++++++++++++++++++++++--------------------- v2/src/development/getconf.sh | 14 ++++--- 5 files changed, 77 insertions(+), 54 deletions(-) create mode 100755 v2/aux/checks/shellcheck.sh diff --git a/v2/aux/checks/shellcheck.sh b/v2/aux/checks/shellcheck.sh new file mode 100755 index 0000000..585a75f --- /dev/null +++ b/v2/aux/checks/shellcheck.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu + +git ls-files | + xargs awk '/^#!\/bin\/sh$/ { print FILENAME } { nextfile }' | + xargs shellcheck -x diff --git a/v2/dynamic.mk b/v2/dynamic.mk index d31be9f..92ff6ee 100644 --- a/v2/dynamic.mk +++ b/v2/dynamic.mk @@ -84,8 +84,15 @@ src/content/.well-known/security.txt: src/content/public.asc.txt src/development sh src/development/security-txt.sh > $@ -check: -dev: check + +test-files = \ + aux/checks/shellcheck.sh \ + +$(test-files): ALWAYS + sh $@ + +check: $(test-files) +dev: all check run: all serve -d public/ @@ -97,3 +104,5 @@ upload: public --delete \ --exclude 's/*' \ public/ $(DOMAIN):/srv/www/ + +ALWAYS: diff --git a/v2/src/bin/makemake b/v2/src/bin/makemake index f4ab87a..06a7d33 100755 --- a/v2/src/bin/makemake +++ b/v2/src/bin/makemake @@ -95,6 +95,7 @@ for r in $RESOURCES; do if [ "$e" = '.md' ]; then continue fi + # shellcheck disable=2016 printf '%s%s = $(%s.md:.md=%s)\n' "$r" "$e" "$r" "$e" done printf '%s =' "$r" @@ -102,6 +103,7 @@ for r in $RESOURCES; do if [ "$e" = '.md' ]; then continue fi + # shellcheck disable=2016 printf ' $(%s%s)' "$r" "$e" done printf '\n' @@ -110,11 +112,12 @@ for r in $RESOURCES; do done all_resources() { - echo $RESOURCES | tr ' ' '\n' + echo "$RESOURCES" | tr ' ' '\n' | grep . } all_vars() { EXT="$1" + # shellcheck disable=2016 all_resources | sed 's|^|$(|' | sed "s|$|$EXT)|" | diff --git a/v2/src/development/genhtml.sh b/v2/src/development/genhtml.sh index cb8fd73..d816fe6 100755 --- a/v2/src/development/genhtml.sh +++ b/v2/src/development/genhtml.sh @@ -72,6 +72,7 @@ FILENAME="${1:-}" eval "$(assert_arg "$FILENAME" 'FILENAME')" +# shellcheck source=/dev/null . "${FILENAME%.md}.conf" # @@ -185,14 +186,16 @@ add_headings_anchors() { } emit_body() { - cat "${FILENAME%.md}.entry-content" | + < "${FILENAME%.md}.content" \ markdown_to_html | extract_plaintext_snippets | add_line_numbers | add_headings_anchors } - +if false; then + emit_body +fi @@ -202,22 +205,22 @@ emit_body() { cat <<-EOF - + - - + + $$title_html - - - + + + - - + +
@@ -237,41 +240,41 @@ EOF exit -.md.rehtml: - F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/reamble."$$lang".html > $@ - -.md.osthtml: - F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/ostamble."$$lang".html > $@ - - - - - - - - -EOF +# .md.rehtml: +# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/reamble."$$lang".html > $@ +# +# .md.osthtml: +# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/ostamble."$$lang".html > $@ +# +# +# +# +# +# +# +# +# EOF # FIXMEs: # - feeds diff --git a/v2/src/development/getconf.sh b/v2/src/development/getconf.sh index dd623f7..4b615a8 100755 --- a/v2/src/development/getconf.sh +++ b/v2/src/development/getconf.sh @@ -74,7 +74,7 @@ escape() { } { - cat src/lib/base-conf | tee "$FILENAME".tmp + tee "$FILENAME".tmp < src/lib/base-conf DELIMITER=0 while read -r line; do if [ "$line" = '---' ]; then @@ -92,9 +92,11 @@ escape() { VALUE="$(printf '%s' "$line" | cut -d: -f2- | sed 's|^ ||' | escape)" printf '%s="%s"\n' "$KEY" "$VALUE" done < "$FILENAME" | tee -a "$FILENAME".tmp + # shellcheck source=/dev/null . "$FILENAME".tmp - cat src/lib/base."$lang".conf + cat src/lib/base."${lang:?}".conf + # shellcheck source=/dev/null . src/lib/base."$lang".conf title="${title:-"$site_name"}" @@ -105,10 +107,10 @@ escape() { printf 'filename="%s"\n' "$FILENAME" printf 'url_part="%s"\n' "$url_part" printf 'url="%s"\n' "$(url-for "$url_part" | absolute)" - printf 'date_formatted="%s"\n' "$(LANG="$lang" date -d "$date" +"$date_fmt" | escape)" - printf 'mailto_uri="%s%s"\n' "$mailto_uri_prefix" "$(uri "$title")" - printf 'discussions_url="%s%s"\n' "$discussions_url_prefix" "$(uri "$title")" - printf 'sourcecode_url="%s%s"\n' "$sourcecode_url_prefix" "$FILENAME" + printf 'date_formatted="%s"\n' "$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}" | escape)" + printf 'mailto_uri="%s%s"\n' "${mailto_uri_prefix:?}" "$(uri "$title")" + printf 'discussions_url="%s%s"\n' "${discussions_url_prefix:?}" "$(uri "$title")" + printf 'sourcecode_url="%s%s"\n' "${sourcecode_url_prefix:?}" "$FILENAME" printf 'lang_url="%s"\n' "$(url-for "$lang"/)" -- cgit v1.2.3