diff --git a/bb.sh b/bb.sh index a53ce6d..c071ea2 100755 --- a/bb.sh +++ b/bb.sh @@ -168,7 +168,7 @@ test_markdown() { good=/tmp/md-good-${RANDOM}.html echo -e "line 1\n\nline 2" > "$in" echo -e "
line 1
\n\nline 2
" > "$good" - $markdown_bin $in > $out 2> /dev/null + "$markdown_bin" "$in" > "$out" 2> /dev/null diff $good $out &> /dev/null # output is irrelevant, we'll check $? if (($? != 0)); then rm -f "$in" "$good" "$out" @@ -182,8 +182,8 @@ test_markdown() { # Parse a Markdown file into HTML and return the generated file markdown() { - out=$(echo $1 | sed 's/md$/html/g') - while [[ -f $out ]]; do out=$(echo $out | sed 's/\.html$/\.'$RANDOM'\.html/'); done + out=${1%.md}.html + while [[ -f $out ]]; do out=${out%.html}.$RANDOM.html; done $markdown_bin "$1" > "$out" echo "$out" } @@ -256,15 +256,15 @@ disqus_footer() { # note that this does not remove$template_tags_line_header"'/ ) print + if (\"$cut_tags\" == \"no\" && /^
$template_tags_line_header/ ) print } } - }' + }" } # Edit an existing, published .html file while keeping its original timestamp @@ -300,11 +300,11 @@ edit() { filename=${1%%.*}.html else # Create the content file - TMPFILE=$(basename $1).$RANDOM.html + TMPFILE=$(basename "$1").$RANDOM.html # Title - echo "$(get_post_title $1)" > "$TMPFILE" + get_post_title "$1" > "$TMPFILE" # Post text with plaintext tags - get_html_file_content 'text' 'text' <$1 | sed "/^
$template_tags_line_header/s|\\1|\\1|g" >> "$TMPFILE" + get_html_file_content 'text' 'text' <"$1" | sed "/^
$template_tags_line_header/s|\\1|\\1|g" >> "$TMPFILE" $EDITOR "$TMPFILE" filename=$1 fi @@ -320,10 +320,10 @@ edit() { touch -t "$touch_timestamp" "$filename" chmod 644 "$filename" echo "Posted $filename" - tags_after=$(tags_in_post $filename) + tags_after=$(tags_in_post "$filename") relevant_tags=$(echo "$tags_before $tags_after" | tr ',' ' ' | tr ' ' '\n' | sort -u | tr '\n' ' ') if [[ ! -z $relevant_tags ]]; then - relevant_posts="$(posts_with_tags $relevant_tags) $filename" + relevant_posts="$(posts_with_tags "$relevant_tags") $filename" rebuild_tags "$relevant_posts" "$relevant_tags" fi } @@ -338,11 +338,11 @@ twitter_card() { echo "" echo "" echo "" # Twitter truncates at 70 char - description=$(grep -v "^
$template_tags_line_header" $1 | sed -e 's/<[^>]*>//g' | head -c 250 | tr '\n' ' ' | sed "s/\"/'/g") + description=$(grep -v "^
$template_tags_line_header" "$1" | sed -e 's/<[^>]*>//g' | head -c 250 | tr '\n' ' ' | sed "s/\"/'/g")
echo ""
- image=$(sed -n 's/.*
$template_comments $template_twitter_button " echo "
" # Get current tweet count - echo '' + echo "" return; else echo "$template_comments "; @@ -387,7 +387,7 @@ twitter() { # Return 0 (bash return value 'true') if the input file is an index, feed, etc # or 1 (bash return value 'false') if it is a blogpost is_boilerplate_file() { - name=$(clean_filename $1) + name=$(clean_filename "$1") case $name in ( "$index_file" | "$archive_index" | "$tags_index" | "$footer_file" | "$header_file" | "$global_analytics_file" | "$prefix_tags"* ) return 0 ;; @@ -404,9 +404,7 @@ is_boilerplate_file() { # $1 the file name # returns the clean file name clean_filename() { - name=$1 - [[ ${name:0:2} == ./ ]] && name=${name:2} # Delete leading './' - echo $name + echo "${1#./}" # Delete leading './' } # Adds all the bells and whistles to format the html page @@ -429,59 +427,61 @@ create_html_page() { # Create the actual blog post # html, head - cat ".header.html" > "$filename" - echo "
's on the title because of markdown conversion - echo "$(echo "$title" | sed 's/<\/*p>//g')" >> "$filename" - echo '
's on the title because of markdown conversion + echo "$title" | sed 's/<\/*p>//g' + echo '