1

I had a functional counting script that broke after I added more in 2 strings. Now the script counts beyond the specified stopping point. I'm stumped. Please help.

# date time counter
# test script - stripped to minimum summary of pertinent parts

# the script worked flawlessly until i added the leading date and trailing timezone
ss_stop=03
mm_stop=00
count_stop="2022-02-28 00:$mm_stop:$ss_stop CST"

# other vars declared

# while loop with if statements that ends in a `break` once string comparison
# [ $count == $count_stop ] was true

##### i believe the problem may be in this string comparison of the modified strings
if [ $count == $count_stop ]; then
    break
fi

Comparison of $count == $count_stop below:

# original
# script view
count="00:$mm_count:$ss_count"
count_stop="00:$mm_stop:$ss_stop"
#shell echo
count="00:00:03"
count_stop="00:00:03"

# modified (this broke the script)
# script view
count="2022-02-28 00:$mm_count:$ss_count CST"
count_stop="2022-02-28 00:$mm_stop:$ss_stop CST"
#shell echo
count="2022-02-28 00:00:03 CST"
count_stop="2022-02-28 00:00:03 CST"

Again: the script worked flawlessly until I added the leading date and trailing timezone. Now the script counts beyond the specified stopping point.

0 Answers0