Accidentially, I found out that wc
counts differently depending on how it gets the input from bash:
$ s='hello'
$ wc -m <<<"$s"
6
$ wc -c <<<"$s"
6
$ printf '%s' "$s" | wc -m
5
$ printf '%s' "$s" | wc -c
5
Is this - IMHO confusing - behaviour documented somewhere? What does wc
count here - is this an assumed newline?
od -c
to see exactly what you have.xxd -g1
.printf "$s"
isn't your actual script... hopefully you meantprintf "%s" "$s"