I found it weird that my program started to output some “b’s” that I did not type. Then I found out this:
var="[|-a]"
echo $var
var="[|-b]"
echo $var
var="[|-c]"
echo $var
.
.
.
The first echo outputs what I intend: [|-a]. The others, from b to z, always output “b”. Why?
You forgot to quote the variable on output, and you have a file called “b” that the character range expression is matching.