Browse Source

[shellcheck refactor] quotes

encrypt 3 years ago
parent
commit
58a254e467
1 changed files with 13 additions and 12 deletions
  1. 13 12
      boh

+ 13 - 12
boh

@@ -23,8 +23,8 @@ boh_help() {
 }
 
 boh_new() {
-    mkdir $destination_dir $layouts_dir
-    cat <<EOF > "$layouts_dir"/default.html
+    mkdir "$destination_dir" "$layouts_dir"
+    cat <<EOF > "$layouts_dir/default.html"
 <!doctype html>
 <html lang="en">
   <head>
@@ -39,12 +39,12 @@ EOF
 }
 
 boh_serve() {
-    cd $destination_dir
+    cd "$destination_dir"
     python2 -m SimpleHTTPServer
 }
 
 boh_check() {
-    if [ ! -d $layouts_dir ];then
+    if [ ! -d "$layouts_dir" ];then
 	>&2 echo "'$layouts_dir' directory not found. Maybe you should 'boh new'"
 	exit 1
     fi
@@ -66,7 +66,7 @@ boh_check() {
 
 boh_parse_frontmatter(){
     frontmatter=$(cat "$1" | sed -n '1{/^---/{:a N;/\n---/!ba;p}}' | sed '1d;$d' | sed -e 's/:[^:\/\/]/="/g;s/$/"/g;s/ *=/=/g')
-    echo $frontmatter
+    echo "$frontmatter"
 }
 
 boh_markdown() {
@@ -76,11 +76,11 @@ boh_markdown() {
 boh_build() {
     echo "Building all the things..."
     rm -rf $destination_dir/*
-    mkdir -p $destination_dir
+    mkdir -p "$destination_dir"
     type boh_pre_build &> /dev/null && { boh_pre_build; }
     # extra "/" is used to increment the final count by 1
-    cut_at=$(echo "/"$source_dir | fold -w 1 | grep -c /)
-    find $source_dir -type f -name "*.md" | while read file
+    cut_at=$(echo "/$source_dir" | fold -w 1 | grep -c /)
+    find "$source_dir" -type f -name "*.md" | while read file
     do
 	layout="default"
 	title=$(echo "$file" | rev | cut -d / -f 1 | rev | sed s/.md//)
@@ -89,7 +89,7 @@ boh_build() {
 	newpath="$destination_dir/"$(echo "$file" | rev | cut -d . -f 2- | rev | cut -d / -f $cut_at-)".html"
 	frontmatter=$(boh_parse_frontmatter "$file")
 	if [ "$frontmatter" ];then
-	    eval $frontmatter
+	    eval "$frontmatter"
 	fi
 	mkdir -p "${newpath%/*}"
 	export title body
@@ -130,12 +130,13 @@ do
     esac
 done
 
+if [ -f "$source_dir/boh.config" ];then
+    source "$source_dir/boh.config"
+fi
+
 case $command in
     "build"|"b")
 	boh_check
-	if [ -f $source_dir"/boh.config" ];then
-	    source $source_dir"/boh.config"
-	fi
 	boh_build
 	;;
     "new")