diff --git a/bb.sh b/bb.sh index 870b91c..0956a53 100755 --- a/bb.sh +++ b/bb.sh @@ -144,7 +144,7 @@ global_variables() { # Markdown location. Trying to autodetect by default. # The invocation must support the signature 'markdown_bin in.md > out.html' - markdown_bin=$(command -v Markdown.pl || command -v markdown) + markdown_bin=$(which Markdown.pl || which markdown) } # Check for the validity of some variables @@ -161,23 +161,8 @@ global_variables_check() { # Test if the markdown script is working correctly test_markdown() { - [[ -z $markdown_bin ]] && return 1 - command -v diff >/dev/null || return 1 - - in=/tmp/md-in-${RANDOM}.md - out=/tmp/md-out-${RANDOM}.html - good=/tmp/md-good-${RANDOM}.html - echo -e "line 1\n\nline 2" > "$in" - echo -e "

line 1

\n\n

line 2

" > "$good" - "$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" - return 1 - fi - - rm -f "$in" "$good" "$out" - return 0 + [[ -n $markdown_bin ]] && + [[ $("$markdown_bin" <<< $'line 1\n\nline 2') == $'

line 1

\n\n

line 2

' ]] }