mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-18 20:47:55 +00:00
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:
parent
a1343666d5
commit
b908e0b8bd
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user