The return
command is used to return an exit status, not an arbitrary string. This is unlike many other languages. You use stdout
to pass data:
getCurrentMinute() {
date +%M | sed -e 's/^0//'
# make sure sed only removes zero from the beginning of the line
# in the case of "00" don't be too greedy so only remove one 0
}
Also, you need more syntax to invoke the function. Currently you are comparing the literal string "getCurrentMinute"
in the if condition
if [[ $(getCurrentMinute) -ge $rangeStartTime_min && ...
I would do if a bit differently
start=13:56
end=15:05
checkIfWithinRange() {
current=$(date +%H:%M) # Get's the current time in the format 05:18
[[ ($start = $current || $start < $current) && ($current = $end || $current < $end) ]]
}
if checkIfWithinRange; then
do something
fi