Hi,
I was wondering if I could get a little help with some korn shell that I cant get quite right.
I want to range check the first 2 parameters so that they are both within the rance 0-23 and that the $GO is less than $STOP before I do anything with the script.
If there is a problem then just report the problem and exit. I thought I could do it in a 1-liner but I'm loosing the plot.
Please could someone review the following and advise.
GO=${1:-3}
STOP=${2:-18}
[[ ${GO}>=0 || ${STOP}<24 ]] && { print "Failed 0 <= START <= 24"; exit 1; }
[[ ${STOP}>=0 || ${STOP}<24 ]] && { print "Failed 0 <= FINISH <= 24"; exit 1; }
[[ ${GO}<${STOP} ]] && { print "Failed START < FINISH"; exit 1; }
Many Thanks
Stephen
I was wondering if I could get a little help with some korn shell that I cant get quite right.
I want to range check the first 2 parameters so that they are both within the rance 0-23 and that the $GO is less than $STOP before I do anything with the script.
If there is a problem then just report the problem and exit. I thought I could do it in a 1-liner but I'm loosing the plot.
Please could someone review the following and advise.
GO=${1:-3}
STOP=${2:-18}
[[ ${GO}>=0 || ${STOP}<24 ]] && { print "Failed 0 <= START <= 24"; exit 1; }
[[ ${STOP}>=0 || ${STOP}<24 ]] && { print "Failed 0 <= FINISH <= 24"; exit 1; }
[[ ${GO}<${STOP} ]] && { print "Failed START < FINISH"; exit 1; }
Many Thanks
Stephen