diff --git a/bb.sh b/bb.sh index 0afc866..5b612dd 100755 --- a/bb.sh +++ b/bb.sh @@ -46,8 +46,6 @@ global_variables() { # Set this to false for a Twitter button with share count. The cookieless version # is just a link. global_twitter_cookieless="true" - # Default search page, where tweets more than a week old are hidden - global_twitter_search="twitter" # Blog generated files # index page of blog (it is usually good to use "index.html" here) @@ -152,7 +150,7 @@ global_variables() { # Markdown location. Trying to autodetect by default. # The invocation must support the signature 'markdown_bin in.md > out.html' - [[ -f Markdown.pl ]] && markdown_bin=./Markdown.pl || markdown_bin=$(which Markdown.pl 2>/dev/null || which markdown 2>/dev/null) + [[ -f Markdown.pl ]] && markdown_bin=./Markdown.pl || markdown_bin=$(command -v Markdown.pl 2>/dev/null || command -v markdown 2>/dev/null) } # Check for the validity of some variables @@ -169,11 +167,12 @@ global_variables_check() { # Test if the markdown script is working correctly test_markdown() { - [[ -n $markdown_bin ]] && - ( - [[ $("$markdown_bin" <<< $'line 1\n\nline 2') == $'

line 1

\n\n

line 2

' ]] || - [[ $("$markdown_bin" <<< $'line 1\n\nline 2') == $'

line 1

\n

line 2

' ]] - ) + local m1; m1=$("$markdown_bin" <<< $'line 1\n\nline 2') + local m2; m2=$("$markdown_bin" <<< $'line 1\n\nline 2') + local c1=$'

line 1

\n\n

line 2

' + local c2=$'

line 1

\n

line 2

' + # shellcheck disable=SC2235 # must enforce order of operations + [[ -n $markdown_bin ]] && ( [[ "$m1" == "$c1" ]] || [[ "$m2" == "$c2" ]] ) } @@ -216,7 +215,8 @@ get_html_file_content() { # "full" to edit full HTML, and not only text part (keeps old filename) # leave empty for default behavior (edit only text part and change name) edit() { - [[ ! -f "${1%%.*}.html" ]] && echo "Can't edit post "${1%%.*}.html", did you mean to use \"bb.sh post \"?" && exit -1 + [[ ! -f "${1%%.*}.html" ]] && \ + printf "Can't edit post \"%s.html\", did you mean to use \"bb.sh post \"?\\n" "${1%%.*}" && exit 1 # Original post timestamp edit_timestamp=$(LC_ALL=C date -r "${1%%.*}.html" +"$date_format_full" ) touch_timestamp=$(LC_ALL=C date -r "${1%%.*}.html" +"$date_format_timestamp") @@ -226,8 +226,7 @@ edit() { filename=$1 else if [[ ${1##*.} == md ]]; then - test_markdown - if (($? != 0)); then + if test_markdown; then echo "Markdown is not working, please edit HTML file directly." exit fi @@ -260,7 +259,8 @@ edit() { echo "Posted $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 + if [[ -n $relevant_tags ]]; then + # shellcheck disable=SC2086 # Intended splitting of $relevant_tags relevant_posts="$(posts_with_tags $relevant_tags) $filename" rebuild_tags "$relevant_posts" "$relevant_tags" fi @@ -324,7 +324,7 @@ is_boilerplate_file() { done case $name in - ( "$index_file" | "$archive_index" | "$gophermap" | "$gemini_index" | "$tags_index" | "$footer_file" | "$header_file" | "$global_analytics_file" | "$prefix_tags"* ) + ( "$index_file" | "$archive_index" | "$gophermap" | "$gemini_index" | "$tags_index" | "$footer_file" | "$header_file" | "$prefix_tags"* ) return 0 ;; ( * ) # Check for excluded for excl in "${html_exclude[@]}"; do @@ -489,8 +489,7 @@ write_entry() { [[ $2 == -html ]] && fmt=html # Test if Markdown is working before re-posting a .md file if [[ $extension == md ]]; then - test_markdown - if (($? != 0)); then + if test_markdown; then echo "Markdown is not working, please edit HTML file directly." exit fi @@ -560,6 +559,7 @@ EOF echo "Posted $filename" relevant_tags=$(tags_in_post $filename) if [[ -n $relevant_tags ]]; then + # shellcheck disable=SC2086 # Intended splitting of $relevant_tags relevant_posts="$(posts_with_tags $relevant_tags) $filename" rebuild_tags "$relevant_posts" "$relevant_tags" fi @@ -616,6 +616,7 @@ all_tags() { { echo "

$template_tags_title

" echo "