From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MLAuD+5afWFLIQEAgWs5BA (envelope-from ) for ; Sat, 30 Oct 2021 16:47:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iKbkCu5afWHwOQAAB5/wlQ (envelope-from ) for ; Sat, 30 Oct 2021 14:47:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 960AF17A6 for ; Sat, 30 Oct 2021 16:47:09 +0200 (CEST) Received: from localhost ([::1]:60278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgpdU-0007uI-OY for larch@yhetil.org; Sat, 30 Oct 2021 10:47:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgpdO-0007u7-IB for guix-patches@gnu.org; Sat, 30 Oct 2021 10:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgpdO-0006Rb-9q for guix-patches@gnu.org; Sat, 30 Oct 2021 10:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgpdO-0003or-3a for guix-patches@gnu.org; Sat, 30 Oct 2021 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51307] [PATCH 0/2] guix hash: eases conversion Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 14:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51307 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: zimoun Cc: 51307@debbugs.gnu.org Received: via spool by 51307-submit@debbugs.gnu.org id=B51307.163560518814628 (code B ref 51307); Sat, 30 Oct 2021 14:47:02 +0000 Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 14:46:28 +0000 Received: from localhost ([127.0.0.1]:58132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgpcp-0003ns-OI for submit@debbugs.gnu.org; Sat, 30 Oct 2021 10:46:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgpco-0003nf-NF for 51307@debbugs.gnu.org; Sat, 30 Oct 2021 10:46:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgpcj-0006PW-EZ; Sat, 30 Oct 2021 10:46:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=+tjRRrur6psz8e3ZD6i2AQyVIudKbWKoNfY00cNSW5I=; b=bc14r2ezY1Ovs3oQ7X5Z Anv9iwwHbMCAWCOvU3i+Jc33pXG7YgKAaGj5uhU/R4ceU+OVhJBxZVW5miwOm7g8+cn9SBz+vXXXf 1bm8fFRSb86dxflrHtNdwdkeVsog3P34qwxUhI6wEIusufai4ti8lNlrZlfkFlCM2jBVz0qdwPI+T FwJcUQYkaJ2dDZ40KnBT428Na8JEkKXXiUL9C3dtSRPGgfVlkb7yrIyas6FOpgExBOtWdw7ZBuP43 6h/hLUQcq15uwL1B55DL6BIn1XMYI+AwP68e+w4X+u5gwRupDFLPCyUmbkqXdsj3qD/zIirLDDNXz uCMPdmpDxFlwQg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:55488 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgpcj-0001yG-23; Sat, 30 Oct 2021 10:46:21 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20211020165020.3358311-1-zimon.toutoune@gmail.com> <20211020165435.3358398-1-zimon.toutoune@gmail.com> Date: Sat, 30 Oct 2021 16:46:18 +0200 In-Reply-To: <20211020165435.3358398-1-zimon.toutoune@gmail.com> (zimoun's message of "Wed, 20 Oct 2021 18:54:34 +0200") Message-ID: <875ytetvt1.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1635605229; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=+tjRRrur6psz8e3ZD6i2AQyVIudKbWKoNfY00cNSW5I=; b=dY3yKL/QqJTNy6AZ5vd7hOWg8Ole4c0jdWiNbgqDZ3QsekERJ+wq5d646g6SfQ2OzvFSSl oNNr2nTLkonThJzXkVmEq3XEQJgaUOIf9KevRKBPcctRtYjc7sLnC9K4RJ4FKH8Ecu1fOB XggwEwtP55gkMrz8qwatqEZdzgW93S5OO1Dma8ijg1fh9ViOhhQp682aQUK7dD7c+gztsD 60gRqpEopKWG073gIBXiJ09RmkrNPww97qx3BY0g402Ju3H587Z7wPAItferLiiND3U2OQ pPbZWm57jtLjMSeV9HQg3JsP1T1aNPI5Jj4v41L/WvHSZA/NTemqUq/Go0R6cw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635605229; a=rsa-sha256; cv=none; b=ZMVzB7k3ZRtG6FG1mBlaf7ukObTgMg0O3YrLgTpr1WIwjemgOrc8kNLpZDo5VR7L0adt2W sXdc+UIGo8iThh/hilCru7bEJdXbFZj/Uvz6EkfxcvJA+O/7dUQF92KuFC3f2cdsvVZ+4V uBAF5hlQUqrMks1+H/N12tQpqLHLKb6/8VJcGReKm89c6sVHRQ8sWpJkIT/nS8Cslx9v1J pdaHu5duDCuYo+BW4Q2wB6OMVZrr6b1+8EwRrS4LslzQvlQe9NAShyoHSwqMuVo0ZQbgeX cn/eEXPZ4XojghQDPpsyNSo+jg2cl1J0EitBCPxU3uhsgjUN4iN9eDE9512FUQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=bc14r2ez; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=bc14r2ez; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 960AF17A6 X-Spam-Score: -2.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: qztoQa+PGICL Hi, zimoun skribis: > * guix/scripts/hash.scm (guix-hash): Allow several files. > [directory?]: New procedure. > [file-hash]: Catch system-error. > [hash-to-display]: New procedure. Nice! Could you update guix.texi and tests/guix-hash.texi? > - (with-error-handling > - (if (assoc-ref opts 'recursive?) > + (if (and (assoc-ref opts 'recursive?) > + (directory? file)) This change is not related to the main purpose of the patch. More importantly, note that =E2=80=98--recursive=E2=80=99 is not limited to= directories: it preserves file properties (directory, executable, or regular), so it=E2=80=99s also useful for executable files for instance. It can also be= used for regular files, even if it=E2=80=99s less useful. > + (define (hash-to-display thing) > + (match thing > + ((? file-exists? file) > + (fmt (file-hash file))) > + ("-" (with-error-handling > + (fmt (port-hash (assoc-ref opts 'hash-algorithm) > + (current-input-port))))) I=E2=80=99d swap the order of the two clauses and remove the call to =E2=80=98file-exists?=E2=80=99: if the file doesn=E2=80=99t exist, =E2=80= =98file-hash=E2=80=99 will raise an error. > + (x > + (leave (G_ "wrong argument~%"))))) > + > + (for-each > + (lambda (arg) > + (format #t "~a~%" (hash-to-display arg))) Or just (compose display hash-to-display) ? Maybe s/hash-to-display/formatted-hash/. Could you send an updated patch? Thanks, Ludo=E2=80=99.