#!/bin/bash
hour="hour" #variable which holds the string for hour
min="min" #variable which holds the string for min
minValue="4"
hourValue="4"
hourEntered="4"
minEntered="4"
###########
# hour #
###########
if [ ! "$hourEntered" ]; then
hourValue=$hourValue
echo "you did not enter an hour"
#if the user did input the correct values take them over
#value to be entered 0 or 23....
elif [[ "$hourEntered" =~ ^[0-23]+$ ]]; then
hourValue=$hourEntered
echo "you entered for hourEntered:$hourEntered"
#else provide a message and provide help....
else
#set the read out values
hourValue=$hourValue
fi
###########
# min #
###########
#check if a value was entered if not take the read out values over
if [ ! "$minEntered" ]; then
minValue=$minValue
echo "you did not enter an min"
#if the user did input the correct values take them over
#value to be entered 0 or 60....
elif [[ "$minEntered" =~ ^[0-59]+$ ]]; then
minValue=$minEntered
echo "you entered for minEntered:$minEntered"
#else provide a message and provide help....
else
#set the read out values
minValue=$minValue
fi
So there is something weird going on, apparently the statement
[[ "$hourEntered" =~ ^[0-23]+$ ]];
does not work, the value 4 is not found. If you change it to 0-59 like so, with the seconds it works perfectly.
Is this a bug, or what is going on here?