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

Re: cat as a builtin command

On Fri, 29 Aug 2014 21:15:57 +0100
Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> 2014-08-29 14:03:43 +0100, Peter Stephenson:
> [...]
> > mycat() {
> >   emulate -L zsh
> >   unsetopt multibyte
> >   zmodload zsh/mapfile
> >   print -r $mapfile[$1]
> > }
> [...]
> That should be:
> print -rn -- $mapfile[$1]
> What would be the possible effects of *not* turning off
> "multibyte" here?

Logically if you have an 8-bit character set defined then the shell
expects command lines to use it and you're relying on the shell
shrugging its shoulders and passing on raw octets anyway, which is
implemented but a bit hit and miss.  However, with just a raw print, and
print expansions turned off, I would hope it works for any input, since
there's not a lot left to go wrong in that case.  It would need scanning
the command argument handling and print code in some detail and with
interestinf failure cases in mind (e.g. partial characters) to be sure.


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