It is for this sort of reason that I use Python instead of shell scripts.
>>> foo = b'foo'
>>> foo[0] == b'f'
False
Don't get me wrong. I love Python, it has been my daily driver for 20+ years (and it pays my salary), but it does have its own set of cognitive burdens.Also, shell scripts I wrote in the 90:s work today. Python scripts - not so much.