Re: Testing time in a korn shell script

joe_at_invalid.address
Date: 01/14/04


Date: Wed, 14 Jan 2004 19:26:49 GMT

Stephane CHAZELAS <this.address@is.invalid> writes:

> 2004-01-14, 17:53(+00), joe@invalid.address:
> [...]
> >> > STARTTIME=0545
> >> > ENDTIME=0700
> >> > GETDATE=`date +%H%M`
> >> >
> >> > if [[ "$GETDATE" -gt "$STARTTIME" && "$GETDATE" -le "$ENDTIME" ]]
> [...]
> >> The above won't work because of the leading 0 in STARTTIME and
> >> ENDTIME. The leading 0 causes arithmetic evaluations to see these as
> >> octal numbers. For example, modify the script like so
> >
> > Please ignore the gibberish I posted here. I need some more caffeine.
> [...]
>
> I don't know what you posted as you seem to have cancelled your
> post, but that's true that in ksh or zsh in ksh emulation mode
> or in bash, they will be considered as octal numbers.

Yes, it was the example that I gave which was messed up.

Joe