removed the 'function' keyword before declaring a function as is not needed.
[bash-notes.git] / SOURCE / CORE / core-add.sh
index aa9d451..1c71bbb 100644 (file)
@@ -1,10 +1,11 @@
-function addnote() {
+addnote() {
        # remove eventually existing temp DB file
        if [[ -f $TMPDB ]]; then
                rm $TMPDB
        fi
 
-       NOTETITLE="$1"
+       RTITLE=$(random_title)
+       [[ -z "$1" ]] && NOTETITLE="$RTITLE" || NOTETITLE="$1"
        echo "adding new note - \"$NOTETITLE\""
        # shellcheck disable=SC2086
        LASTID=$($JQ '.notes[-1].id // 0 | tonumber' $DB)