Check if there's an empty title

This commit is contained in:
Ricky Jon 2018-10-29 22:39:58 +11:00
parent 6c7fcd73d8
commit f51582265b
1 changed files with 3 additions and 0 deletions

3
lb
View File

@ -34,6 +34,9 @@ getTitle() { \
echo "Post will be stored as draft in $draftdir until finalized."
read -rp "Give a title for your post: " title
url=$(echo "$title" | tr -d '[:punct:]' | tr " " "-" | tr '[:upper:]' '[:lower:]')
[ -z $url ] && echo "Error: Empty title!" && return 0;
grep "$url" "$blogfile" &>/dev/null && lbdupnum=1 && while [ grep "$url" "$blogfile" ]; do lbdupnum=$((lbdupnum+1)); done
[ ! -z ${lbdupnum+x} ] && url="$url"-"$lbdupnum"
return 0