don't write directly to $index, use proxy $indexfile first

This commit is contained in:
nytpu 2020-09-12 10:37:19 -06:00
parent e2a86b3b6b
commit 8598ef396b
Signed by: nytpu
GPG Key ID: ECCDC07B337B8F5B
1 changed files with 11 additions and 3 deletions

View File

@ -42,7 +42,7 @@ get_post_title() {
}
make_atom() {
echo "Making Atom"
echo "Bulding atom feed..."
atomfile="$gemlog_feed.$RANDOM"
while [[ -f $atomfile ]]; do atomfile="$gemlog_feed.$RANDOM"; done
@ -88,7 +88,11 @@ EOF
}
build_entries() {
echo "Building entries"
echo "Building index..."
indexfile="$index.$RANDOM"
while [[ -f $indexfile ]]; do indexfile="$index.$RANDOM"; done
{
# header of the page (above the posts list)
sed 's/$/\r/g' << 'EOF'
@ -124,7 +128,10 @@ EOF
=> https://tildegit.org/nytpu/gemlog.sh generated with gemlog.sh
EOF
} 3>&1 >"$index"
} 3>&1 >"$indexfile"
mv "$indexfile" "$index"
chmod 644 "$index"
}
toot() {
@ -133,6 +140,7 @@ toot() {
read -r -p "do you want to toot the newest post? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "tooting..."
# change this if you want the toot to have different content
printf "new gemlog post: ${title}\n\ngemini://nytpu.com/gemlog/${filename}" | toot post
fi