Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

EILSEQ in the C locale? (Was: $(<nofile) doesn't set $? to non-zero)



2018-03-15 07:12:04 +0000, Stephane Chazelas:
[...]
> $ sudo ./Src/zsh -c 'ERRNO=0; v=$(</dev/mem); echo $? $ERRNO $#v'
> zsh:1: error when reading /dev/mem: operation not permitted
> 1 1 1046296
[...]

BTW, when swapping $#v and $ERRNO above, I noticed that I was
seeing some EILSEQ errors even in the C locale because of
"malformed characters".

I wouldn't expect to get those in a C locale or other locales
with single-byte charsets.

$ a=$'\x80' LC_ALL=C zsh -c 'ERRNO=0; echo $#a $ERRNO'
1 84
$ syserror 84
Invalid or incomplete multibyte or wide character

Maybe some optimisation could be done and things like mbstowc()
avoided when MB_CUR_MAX is 1 or something like that?

(here, I beleive my mbstowc() returns EILSEQ in the C locale for
byte values above 0x7f).

(maybe not worth the effort).

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author