change-time: Don't offer minimum field value as default

There's little value to offering the minimum field value as a default
IMO:
* it's rarely accurate (e.g. minute 00 is only accuate 1/60 of the time)
* it's very obvious to just press '0'<enter> instead (and no longer
  needs to be '00')
* it eliminates a lot of wordiness you otherwise have to read (or more
  likely, ignore)

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2024-08-06 09:26:36 -04:00
parent a1343666d5
commit b908e0b8bd
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114

View File

@ -13,23 +13,16 @@ get_date () {
min="$2"
max="$3"
digits="$4"
echo -e -n "Please insert $field_name (between $min-$max) (Enter key to accept $min)\n"
echo "Please insert $field_name (between $min-$max)"
read -r value
echo -e "\n"
#if enter
if [[ $value = "" ]]; then
value=$min
fi
echo
#must be a number between $2 and $3
while [[ ! $value =~ ^[0-9]*$ ]] || [[ ${value#0} -lt $min ]] || [[ ${value#0} -gt $max ]];
while [[ ! $value =~ ^[0-9]+$ ]] || [[ ${value#0} -lt $min ]] || [[ ${value#0} -gt $max ]];
do
echo -e -n "$field_name is wrong: you entered \"$value\". Please try again, it must be a number between $min and $max (press Enter to accept $min) \n"
echo "$field_name is wrong: you entered \"$value\". Please try again, it must be a number between $min and $max"
read -r value
echo -e "\n"
if [[ $value = "" ]]; then
value=$min
fi
echo
done
# Pad with zeroes to digits