From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27227 invoked by alias); 1 Sep 2014 08:51:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33083 Received: (qmail 16379 invoked from network); 1 Sep 2014 08:51:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f156d0000063c7-ae-540431374629 Date: Mon, 01 Sep 2014 09:41:26 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: cat as a builtin command Message-id: <20140901094126.4d46e733@pwslap01u.europe.root.pri> In-reply-to: <20140829201557.GD28052@chaz.gmail.com> References: <20140829140343.7ed2a891__13925.6726870828$1409317564$gmane$org@pwslap01u.europe.root.pri> <20140829201557.GD28052@chaz.gmail.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4FV1zQ5YQgy8HdS0ONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXxqvVLcwFL9grNu22bGDsZ+ti5OSQEDCRaDu1iBXCFpO4cG89 UJyLQ0hgKaNE37tt7CAJIYHlTBL/n0iB2CwCqhKTl18Gi7MJGEpM3TSbEcQWERCXOLv2PAuI LQxUM3t5L9hQXgF7iSkTL4PFOYGWbflxmRViwRFGiTVT+phBEvwC+hJX/35igrjCXmLmlTOM EM2CEj8m3wNrZhbQkti8rYkVwpaX2LzmLfMERoFZSMpmISmbhaRsASPzKkbR1NLkguKk9FxD veLE3OLSvHS95PzcTYyQEPyyg3HxMatDjAIcjEo8vC8WMocIsSaWFVfmHmKU4GBWEuEVNGAJ EeJNSaysSi3Kjy8qzUktPsTIxMEp1cBoG77n0IMdnAnJj+6eskkp0085qnGnwa9y7iX7iQkf b56qeH7wNo975W/NrvJTTzsOfkmyE/6/sWShmu6/pVdETZPqkhZOvaHL4bx53nvFp9pPt0h3 nwx5HXpcwzlrzuNl3i381fFXvF59rAsQ4Cs2XKZ40SZnaWpUwYszDi81F2oeeh7cksOrxFKc kWioxVxUnAgAch2vyh8CAAA= On Fri, 29 Aug 2014 21:15:57 +0100 Stephane Chazelas 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