use file extension when posting with bb.sh post file.ext

but let users override it with `bb.sh post -html file.md`
This commit is contained in:
Alexey Shpakovsky 2014-06-26 04:13:29 +02:00 committed by Aleksei Shpakovskii
parent 555db3167f
commit 7d67da7b27

6
bb.sh
View file

@ -594,9 +594,11 @@ write_entry() {
delete_includes
exit
fi
# check if TMPFILE is markdown even though the user didn't specify it
# guess format from TMPFILE
extension="${TMPFILE##*.}"
[[ "$extension" == "md" ]] && fmt="md"
[[ "$extension" == "md" || "$extension" == "html" ]] && fmt="$extension"
# but let user override it (`bb.sh post -html file.md`)
[[ "$2" == "-html" ]] && fmt="html"
else
TMPFILE=".entry-$RANDOM.$fmt"
echo -e "Title on this line\n" >> "$TMPFILE"