diff --git a/generatePostHtml b/generatePostHtml
index 9ef99ad..a6a7c5c 100755
--- a/generatePostHtml
+++ b/generatePostHtml
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# $1 = Input file
# $2 = Post ID
-if [[ $# < 2 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
+if [[ $# -lt 2 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 "
exit 1
fi
diff --git a/getPostTitle b/getPostTitle
index 764f5ed..3b711dd 100755
--- a/getPostTitle
+++ b/getPostTitle
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#STDIN = post content
-head -n 1 | sed -r 's/^#+//g'
+head -n 1 | sed -r 's/^[# ]+//g'
diff --git a/idUnpublish b/idUnpublish
index 211a576..18600e7 100755
--- a/idUnpublish
+++ b/idUnpublish
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
+if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 "
exit 1
fi
@@ -8,7 +8,7 @@ fi
postid="$1"
echo -n "Unpublish $postid? [y/N] "
-read confirm
+read -r confirm
if [[ "$confirm" = "y" ]]; then
rm "public/posts/$postid.html"
rm "source/post_date/$postid"
diff --git a/makeIndex b/makeIndex
index 9a63f31..a5af75c 100755
--- a/makeIndex
+++ b/makeIndex
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
+if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 "
exit 1
fi
@@ -16,10 +16,9 @@ function postList() {
#Get post list in reverse order and retrieve the last $indexLength posts
#Generates HTML for them with the title and blurbs
#Then removes the last two lines of the output to delete the extra
- cat source/post_list \
- | perl -e 'print reverse <>' \
+ perl -e 'print reverse <>' < source/post_list \
| head -n "$indexLength" \
- | while read postid; do
+ | while read -r postid; do
#Escape single quotes
link="$(echo "posts/$postid.html" | sed "s/'/\\'/g")"
echo "
diff --git a/publish b/publish
index c552d21..96ca193 100755
--- a/publish
+++ b/publish
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
+if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 "
exit 1
fi
@@ -31,7 +31,7 @@ blurb="$(tail -n +2 < "$file" \
date="$(date '+%b %d, %Y')"
#Replace spaces with dashes in the title, and lowercase it
-postid="$(echo $title | ./getPostID)"
+postid="$(echo "$title" | ./getPostID)"
echo "ID: $postid"
echo "Title: $title"
@@ -40,28 +40,28 @@ echo ""
if grep "$postid" "source/post_list" &> /dev/null; then
echo -n "Post exists with ID '$postid'. Update post? [y/N] "
- read confirm_post
+ read -r confirm_post
if [[ "$confirm_post" != "y" ]]; then
exit 1
fi
else
echo -n "Are you sure you want to post '$title'? [y/N] "
- read confirm_post
+ read -r confirm_post
if [[ "$confirm_post" != "y" ]]; then
exit 1
else
- echo -n $title > "source/post_title/$postid"
- echo -n $date > "source/post_date/$postid"
- echo $postid >> "source/post_list"
+ echo -n "$title" > "source/post_title/$postid"
+ echo -n "$date" > "source/post_date/$postid"
+ echo "$postid" >> "source/post_list"
fi
fi
#Regenerate blurb when editing posts
-echo -n $blurb > "source/post_blurb/$postid"
+echo -n "$blurb" > "source/post_blurb/$postid"
./generatePostHtml "$file" "$postid"
POST="source/post_content/$postid.html" \
-TITLE="$title"
+TITLE="$title" \
./makePost > "./public/posts/$postid.html"
./makeIndices
diff --git a/regenPosts b/regenPosts
index 5124ab5..550d6e9 100755
--- a/regenPosts
+++ b/regenPosts
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
find ./posts -type f \
- | while read postfile; do
+ | while read -r postfile; do
title="$(./getPostTitle < "$postfile")"
- postid="$(echo $title | ./getPostID)"
+ postid="$(echo "$title" | ./getPostID)"
if grep "$postid" "source/post_list" &> /dev/null; then
echo "Regenerating $postid"
./generatePostHtml "$postfile" "$postid"
diff --git a/unpublish b/unpublish
index 48883fc..918aa92 100755
--- a/unpublish
+++ b/unpublish
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
-if [[ $# < 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
+if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
echo "Usage: $0 "
exit 1
fi
title="$(./getPostTitle < "$1")"
-postid="$(echo $title | ./getPostID)"
+postid="$(echo "$title" | ./getPostID)"
./unpublish "$postid"