sbs

A Simple Blogging System.
git clone https://git.sr.ht/~jbauer/sbs
Log | Files | Refs | README | LICENSE

commit 7a966eaf612edd92523713dc2ae86981e0058748
parent 4fb81b9cc7e4aa06565f3f120ff399d518081fe4
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Tue, 22 Feb 2022 15:17:24 -0500

Pipe commands into while loops (SC2044)

Diffstat:
Msbs | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sbs b/sbs @@ -107,16 +107,15 @@ if [ "$1" = "genfeed" ]; then printf "\t<generator>sbs</generator>\n\n" } > static/feed.xml - numEntries=0 tmp=$(mktemp) - for file in $(find content/"$blogDir" -type f -name '*.md'); do + find content/"$blogDir" -type f -name '*.md' | while read -r file; do if [ -n "$(lowdown -X draft "$file" 2>/dev/null)" ]; then continue fi printf "%s %s\n" "$(date -d "$(lowdown -X date "$file")" +"%s")" \ "$file" >> "$tmp" done - for file in $(sort -rn "$tmp" | cut -d' ' -f2); do + sort -rn "$tmp" | cut -d' ' -f2 | while read -r file; do fileName=$(basename "$file" .md).html subDir=$(dirname "$file" | sed "s/^content\/?//") @@ -133,10 +132,9 @@ if [ "$1" = "genfeed" ]; then printf "\t\t<content type=\"text\"><![CDATA[\n%s\n\t\t]]></content>\n" "$(lowdown $buildOptions "$file")" printf "\t</entry>\n\n" } >> static/feed.xml - - numEntries=$((numEntries+1)) done + numEntries="$(wc -l "$tmp" | cut -d' ' -f1)" printf '</feed>\n' >> static/feed.xml printf "Created: static/feed.xml with %s entries.\n" "$numEntries" rm "$tmp"