zsh-workers
 help / color / mirror / code / Atom feed
* Re: cat as a builtin command
       [not found] <BLU436-SMTP2045383EF41756D3376DB3CF4DB0__18289.847582537$1409277048$gmane$org@phx.gbl>
@ 2014-08-29 20:21 ` Stephane Chazelas
  0 siblings, 0 replies; 3+ messages in thread
From: Stephane Chazelas @ 2014-08-29 20:21 UTC (permalink / raw)
  To: zsh-workers

You could do something like:

zmodload zsh/system
cat() for i do while sysread -o 1; do : ;done < $i; done


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: cat as a builtin command
  2014-08-29 20:15   ` Stephane Chazelas
@ 2014-09-01  8:41     ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2014-09-01  8:41 UTC (permalink / raw)
  To: zsh-workers

On Fri, 29 Aug 2014 21:15:57 +0100
Stephane Chazelas <stephane.chazelas@gmail.com> 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.

pws


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: cat as a builtin command
       [not found] ` <20140829140343.7ed2a891__13925.6726870828$1409317564$gmane$org@pwslap01u.europe.root.pri>
@ 2014-08-29 20:15   ` Stephane Chazelas
  2014-09-01  8:41     ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Stephane Chazelas @ 2014-08-29 20:15 UTC (permalink / raw)
  To: zsh-workers

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?

-- 
Stephane


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-01  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <BLU436-SMTP2045383EF41756D3376DB3CF4DB0__18289.847582537$1409277048$gmane$org@phx.gbl>
2014-08-29 20:21 ` cat as a builtin command Stephane Chazelas
     [not found] <BLU436-SMTP2045383EF41756D3376DB3CF4DB0@phx.gbl>
     [not found] ` <20140829140343.7ed2a891__13925.6726870828$1409317564$gmane$org@pwslap01u.europe.root.pri>
2014-08-29 20:15   ` Stephane Chazelas
2014-09-01  8:41     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).