Single-byte operations on vars broken
Vladimir Kudrya <[email protected]> Sat, 13 Jun 2026 00:56:46 +0300
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
Hi!
It seems that this commit c5bf9702 changed behavior of ${var#?} under
LC_ALL=C, which should consider characters to be one byte long and cut
accordingly.
This code:
var=联;
LC_ALL=C
while [ -n "$var" ]; do
cut_var=${var#?}
byte=${var%"$cut_var"}
printf '>%02x<\n' "'$byte"
var=$cut_var
done
unset LC_ALL
should output:
>e8<
>81<
>94<
It works reliably in sh 0.5.12, also ash, bash, zsh (both in POSIX and
native modes), but is broken in dash 0.5.13.
More context can be found at:
https://github.com/Vladimir-csp/app2unit/issues/17