From bfc139e689fc81defdf7c9da47546f60979465d9 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sat, 27 Jul 2024 21:07:58 -0400 Subject: [PATCH] Make ask_pn() more friendly --- workflow/qhtcp-workflow | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/workflow/qhtcp-workflow b/workflow/qhtcp-workflow index 7ae03e6e..ea9613a4 100755 --- a/workflow/qhtcp-workflow +++ b/workflow/qhtcp-workflow @@ -226,13 +226,30 @@ err() { echo "Error: $*" >&2; } ask_pn() { unset PROJECT declare -g PROJECT - word1=$(shuf -n 1 /usr/share/dict/words) - word2=$(shuf -n 1 /usr/share/dict/words) - word3=$(shuf -n 1 /usr/share/dict/words) - read -r -p "Enter a new or existing project name, ex. ${PROJECT_PREFIX}_${word1}_${word2}_${word3}: " PROJECT + cat <<-EOF + Enter a new or existing project name, ex. ${PROJECT_PREFIX}_$(random_words 3) + If entering a new project, use the suggested prefix: ${PROJECT_PREFIX}_ + You may choose any combination of words/characters following the prefix, but be sensible. + Make it descriptive and avoid spaces and special characters. + EOF + read -r -p "Enter a new or existing project name: " PROJECT [[ -z $PROJECT ]] } debug() { (( DEBUG )) && echo "Debug: $*"; } +# Not super portable but nice to have +random_words() { + local num=${1:-2} + local -a arr + for ((i=0;i