duplicate entry name handling

This commit is contained in:
Luke Smith 2018-09-03 12:57:04 -04:00
parent 21cbc410af
commit a91ffe925d
1 changed files with 4 additions and 1 deletions

5
lb
View File

@ -32,7 +32,10 @@ listandReturn() { \
getTitle() { \
echo "Post will be stored as draft in $draftdir until finalized."
read -rp "Give a title for your post: " title
url=$(echo $title | sed -e "s/'\|\"\|=\|+\|_\|,\|\.\|:\|;\|?\|!\|@\|\*\|&\|(\|)\|[\|]\|<\|>//g;s/ /-/g" | tr '[:upper:]' '[:lower:]') ;}
url=$(echo $title | sed -e "s/'\|\"\|=\|+\|_\|,\|\.\|:\|;\|?\|!\|@\|\*\|&\|(\|)\|[\|]\|<\|>//g;s/ /-/g" | tr '[:upper:]' '[:lower:]')
grep "$url" "$blogfile" &>/dev/null && lbdupnum=1 && while [ grep "$url" "$blogfile" ]; do lbdupnum=$((lbdupnum+1)); done
[ ! -z ${lbdupnum+x} ] && url="$url"-"$lbdupnum"
}
postNew() { \
mkdir -p "$draftdir"