From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17610 invoked by alias); 30 Oct 2016 17:09:12 -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: 39776 Received: (qmail 4534 invoked from network); 30 Oct 2016 17:09:12 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.402083 secs); 30 Oct 2016 17:09:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=lQbbMJM+uMTXDR8 urC7c81LbAEU=; b=Fh0CUrgXSDwnZvY8a/1oETqWCsALBTV4gidOLzZKP5BQndo xb9k7aBs2tRSZXZYm+peWiI6DhmFz3yqHlo7iA9WoW45kaKpK8VHrKgyubRvSszy R9ubzJrggtSREjMlo/NkJWQIyaKhYtY04taeQbk+tZSdvyReudc7Qx/HptnE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=lQbbMJM+uMTXDR 8urC7c81LbAEU=; b=lqOwPH9vByAIKBI5Te3rx/h5kQlegEdnLrSY0BLIb02vww HuiFbjVXVX8r2e+c5EJG/psHKiWDT9CSOYSxDkBuNOBBogmWuHBzfZea//U6awK7 EhxsqteOY5Og8wku21iJveHJBeLuOt4KXt7FQ8vwbDYqjQMwU9PrkIGeYxafQ= X-ME-Sender: X-Sasl-enc: J89e+0cP/658V9kq7g8lv/Xm+hLzEoqt0fO0p+B9d8Dt 1477847346 Date: Sun, 30 Oct 2016 17:06:58 +0000 From: Daniel Shahaf To: Frank Terbeck Cc: Reed Riley , zsh-workers@zsh.org Subject: Re: [PATCH] Fix hexdump command used for mercurial dirstate parsing Message-ID: <20161030170534.GA17437@fujitsu.shahaf.local2> References: <20161030024723.62832-1-john.reed.riley@gmail.com> <87y416drcq.fsf@ft.bewatermyfriend.org> <20161030155530.GC12137@fujitsu.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161030155530.GC12137@fujitsu.shahaf.local2> User-Agent: Mutt/1.5.23 (2014-03-12) Daniel Shahaf wrote on Sun, Oct 30, 2016 at 15:55:30 +0000: > Frank Terbeck wrote on Sun, Oct 30, 2016 at 12:11:01 +0100: > > It would be conceivable to make the command that is called in these > > places configurable via styles. But that is a separate issue to the > > one that fixes our use of hexdump. > > Couldn't we replace hexdump by a pure zsh solution? We simply need to > read 20 octets and print their hexadecimal values. This seems to do the job: % f() { local fname=$1 bytecount=$2 # Read 20 bytes setopt localoptions nomultibyte integer fd; local val exec {fd}<$fname read -k $bytecount -r -u $fd val exec {fd}<&- # Convert them to hex setopt localoptions extendedglob local -r -A pad=( $'\0' 0 $'\1' 0 $'\2' 0 $'\3' 0 $'\4' 0 $'\5' 0 $'\6' 0 $'\7' 0 $'\10' 0 $'\11' 0 $'\12' 0 $'\13' 0 $'\14' 0 $'\15' 0 $'\16' 0 $'\17' 0 ) REPLY=${(L)val//(#b)(?)/$pad[$match[1]]$(( [##16] ##${match[1]} ))} } % f dirstate 20 % typeset -p REPLY typeset REPLY=77bba665e970146bd2be0b2da40092e340408804 % xxd -l20 -p < dirstate 77bba665e970146bd2be0b2da40092e340408804 % Would something along these lines be preferable? Thanks to Mikael for the inner loop. Cheers, Daniel