summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-05-12 09:06:22 +0100
committerPaul Buetow <git@mx.buetow.org>2021-05-21 05:11:04 +0100
commitbdf56f978f490f97e89afb6650e3a1913abd8e28 (patch)
tree3f673b8e5d78c3ca9326a9e592c3616f46ab2051
parenta453bf2f909e0ea01b0649ce8dc42d54689f738f (diff)
make shellcheck happy again, also add a shellcheck makefile target
-rw-r--r--Makefile11
-rwxr-xr-xbuetow.org.sh3
-rw-r--r--modules/atomfeed.source.sh2
-rw-r--r--modules/gemfeed.source.sh2
-rw-r--r--modules/generate.source.sh21
-rw-r--r--modules/html.source.sh1
6 files changed, 26 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 5c6689df..cdd6f0f8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,15 @@ all: generate
generate:
bash ./buetow.org.sh --generate
publish:
- ADD_GIT=yes bash ./buetow.org.sh --generate
+ ADD_GIT=yes ./buetow.org.sh --generate
git commit -a
git push
+test: shellcheck
+ ./buetow.org.sh --test
+shellcheck:
+ shellcheck \
+ --norc \
+ --external-sources \
+ --check-sourced \
+ --exclude=SC2155,SC2010,SC2154,SC1090 \
+ buetow.org.sh
diff --git a/buetow.org.sh b/buetow.org.sh
index 228afcce..bd89d648 100755
--- a/buetow.org.sh
+++ b/buetow.org.sh
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
+#
+# The buetow.org.sh static site generator
+# by Paul Buetow 2021
declare -r ARG=$1; shift
declare DATE=date
diff --git a/modules/atomfeed.source.sh b/modules/atomfeed.source.sh
index 01608fe5..e9402119 100644
--- a/modules/atomfeed.source.sh
+++ b/modules/atomfeed.source.sh
@@ -16,7 +16,7 @@ atomfeed::meta () {
# Extract first paragraph from Gemtext
local summary=$($SED -n '/^[A-Z]/ { p; q; }' "$gmi_file_path" | tr '"' "'")
# Extract the date from the file name.
- local filename_date=$(basename $gmi_file_path | cut -d- -f1,2,3)
+ local filename_date=$(basename "$gmi_file_path" | cut -d- -f1,2,3)
local date=$($DATE --iso-8601=seconds --date "$filename_date $($DATE +%H:%M:%S)")
cat <<META | tee "$meta_file"
diff --git a/modules/gemfeed.source.sh b/modules/gemfeed.source.sh
index 7e1c476b..66ed48fc 100644
--- a/modules/gemfeed.source.sh
+++ b/modules/gemfeed.source.sh
@@ -32,7 +32,7 @@ cat <<GEMFEED > "$gemfeed_dir/index.gmi.tmp"
GEMFEED
- gemfeed::get_posts | while read gmi_file; do
+ gemfeed::get_posts | while read -r gmi_file; do
# Extract first heading as post title.
local title=$($SED -n '/^# / { s/# //; p; q; }' "$gemfeed_dir/$gmi_file" | tr '"' "'")
# Extract the date from the file name.
diff --git a/modules/generate.source.sh b/modules/generate.source.sh
index 7066576a..b82b5671 100644
--- a/modules/generate.source.sh
+++ b/modules/generate.source.sh
@@ -15,7 +15,7 @@ generate::make_link () {
done < <(echo "$line" | tr ' ' '\n')
if grep -E -q "$IMAGE_PATTERN" <<< "$link"; then
- if [ $what == md ]; then
+ if [ "$what" == md ]; then
md::make_img "$link" "$descr"
else
html::make_img "$link" "$(html::special "$descr")"
@@ -23,7 +23,7 @@ generate::make_link () {
return
fi
- if [ $what == md ]; then
+ if [ "$what" == md ]; then
md::make_link "$link" "$descr"
else
html::make_link "$link" "$(html::special "$descr")"
@@ -38,11 +38,11 @@ generate::fromgmi_ () {
local dest_dir=$(dirname "$dest")
test ! -d "$dest_dir" && mkdir -p "$dest_dir"
- if [ $format == html ]; then
+ if [ "$format" == html ]; then
cat header.html.part > "$dest.tmp"
html::fromgmi < "$src" >> "$dest.tmp"
cat footer.html.part >> "$dest.tmp"
- elif [ $format == md ]; then
+ elif [ "$format" == md ]; then
md::fromgmi < "$src" >> "$dest.tmp"
fi
@@ -61,13 +61,14 @@ generate::fromgmi_add_docs () {
test "$ADD_GIT" == yes && git add "$dest"
}
-generate::fromgmi_convert_atom () {
+generate::convert_gmi_atom_to_html_atom () {
local -r format="$1"; shift
+ test "$format" != html && return
- test $format != html && return
$SED 's|.gmi|.html|g; s|gemini://|https://|g' \
< $CONTENT_DIR/gemtext/gemfeed/atom.xml \
> $CONTENT_DIR/html/gemfeed/atom.xml
+
test "$ADD_GIT" == yes && git add $CONTENT_DIR/html/gemfeed/atom.xml
}
@@ -81,14 +82,14 @@ generate::fromgmi_cleanup () {
}
generate::fromgmi () {
- find $CONTENT_DIR/gemtext -type f -name \*.gmi | while read -r src; do
+ find "$CONTENT_DIR/gemtext" -type f -name \*.gmi | while read -r src; do
for format in "$@"; do
generate::fromgmi_ "$src" "$format"
done
done
# Add non-.gmi files to html dir.
- find $CONTENT_DIR/gemtext -type f | grep -E -v '(.gmi|atom.xml|.tmp)$' |
+ find "$CONTENT_DIR/gemtext" -type f | grep -E -v '(.gmi|atom.xml|.tmp)$' |
while read -r src; do
for format in "$@"; do
generate::fromgmi_add_docs "$src" "$format"
@@ -97,12 +98,12 @@ generate::fromgmi () {
# Add atom feed for HTML
for format in "$@"; do
- generate::fromgmi_convert_atom "$format"
+ generate::convert_gmi_atom_to_html_atom "$format"
done
# Remove obsolete files from ./html/
for format in "$@"; do
- find $CONTENT_DIR/$format -type f | while read -r src; do
+ find "$CONTENT_DIR/$format" -type f | while read -r src; do
generate::fromgmi_cleanup "$src" "$format"
done
done
diff --git a/modules/html.source.sh b/modules/html.source.sh
index 9fb4a301..ef6e7b11 100644
--- a/modules/html.source.sh
+++ b/modules/html.source.sh
@@ -47,7 +47,6 @@ html::make_link () {
}
html::fromgmi () {
- local -r gmi_file=$1
local -i is_list=0
local -i is_plain=0