You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] printf %d with a multibyte char constant uses the code point in the C locale; GNU uses the first byte #2965
area:builtinsbuiltin semantics (printf/declare/command/type/...)bugSomething isn't workinggnu-baselineTracked by the GNU Bash 5.3.0 true-baseline ledger
In a single-byte locale, the '<char> character constant of printf %d
takes the first byte of the character: é is UTF-8 0xC3 0xA9, so GNU
prints 195.
Actual (rubash)
rubash prints 233, the Unicode code point U+00E9, regardless of locale.
Scope
The divergence is C-locale-only: under LC_ALL=C.UTF-8 both shells print 233 for 'é and 8364 for '€. Morphology (all in LC_ALL=C, two
passes, stable):
input
GNU
rubash
'é
195
233
'ü
195
252
'€
226
8364
'😀
240
128512
'ß
195
223
'ñ
195
241
'Ā
196
256
'é'€ (two args)
195 226
233 8364
Same in both shells (controls): ASCII 'a → 97; C.UTF-8 'é/'€ →
233/8364; invalid bytes $'\xff' / $'\x80' → identical invalid number
diagnostic, rc 1; printf '%d' "'" → 0; $(( 'é' )) is an arithmetic
syntax error in both shells (no char-constant support on that surface).
Environment
rubash master 5133187592fd6f97ed55f0260762475f3986e337 (fresh build,
verified on that binary)
area:builtinsbuiltin semantics (printf/declare/command/type/...)bugSomething isn't workinggnu-baselineTracked by the GNU Bash 5.3.0 true-baseline ledger
Activity
fix: printf char constant reads arg[1] as bytes under the active loca…
fix: printf char constant follows the locale byte/char rule (Refs uni…