From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MK6YLrZ02l5ZYAAA0tVLHw (envelope-from ) for ; Fri, 05 Jun 2020 16:37:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id cMRzKrZ02l6HPQAAbx9fmQ (envelope-from ) for ; Fri, 05 Jun 2020 16:37: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 EE3A594050A for ; Fri, 5 Jun 2020 16:37:09 +0000 (UTC) Received: from localhost ([::1]:55432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhFL9-0007yp-IT for larch@yhetil.org; Fri, 05 Jun 2020 12:37:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhFL4-0007xI-FH for guix-patches@gnu.org; Fri, 05 Jun 2020 12:37:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhFL4-0007Jc-3z for guix-patches@gnu.org; Fri, 05 Jun 2020 12:37:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jhFL4-00025W-1d for guix-patches@gnu.org; Fri, 05 Jun 2020 12:37:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41253] [PATCH v3] guix repl: Add script execution. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 05 Jun 2020 16:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41253 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Konrad Hinsen Cc: 41253@debbugs.gnu.org, zimoun Received: via spool by 41253-submit@debbugs.gnu.org id=B41253.15913749917989 (code B ref 41253); Fri, 05 Jun 2020 16:37:01 +0000 Received: (at 41253) by debbugs.gnu.org; 5 Jun 2020 16:36:31 +0000 Received: from localhost ([127.0.0.1]:49735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhFKZ-00024n-3I for submit@debbugs.gnu.org; Fri, 05 Jun 2020 12:36:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhFKX-00024b-Un for 41253@debbugs.gnu.org; Fri, 05 Jun 2020 12:36:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41439) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhFKS-0007Fz-JC; Fri, 05 Jun 2020 12:36:24 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=50324 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jhFKS-00010h-4H; Fri, 05 Jun 2020 12:36:24 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200514162537.29071-1-zimon.toutoune@gmail.com> <87img698gn.fsf@gnu.org> Date: Fri, 05 Jun 2020 18:36:21 +0200 In-Reply-To: (Konrad Hinsen's message of "Fri, 05 Jun 2020 10:48:53 +0200") Message-ID: <87d06d1ncq.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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-Spam-Score: -1.01 X-TUID: gDh/tc9aVPZK Hello Konrad, Konrad Hinsen skribis: >> It cannot be used as a shebang, can it? > > It can. And that might be worth documenting. Here's an example: > > =3D=3D=3D=3D=3D File foo.scm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > #!/usr/bin/env -S guix repl > !# > (use-modules (ice-9 format)) > > (format #t "foo called with arguments: ~s\n"(command-line)) > =3D=3D=3D=3D=3D End of file foo.scm =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > hinsen@guix ~$ ~/foo.scm a b c > ;;; note: source file /home/hinsen/temp/foo.scm > ;;; newer than compiled /home/hinsen/.cache/guile/ccache/3.0-LE-8= -4.2/home/hinsen/temp/foo.scm.go > foo called with arguments: ("/home/hinsen/temp/foo.scm" "a" "b" "c") Nice! > The ugly part is that the script needs to be called with '=E2=80=93' as i= ts > first argument if any of the following arguments start with dashes: > > hinsen@guix ~$ ~/foo.scm -- --help > ;;; note: source file /home/hinsen/temp/foo.scm > ;;; newer than compiled /home/hinsen/.cache/guile/ccache/3.0-LE-8= -4.2/home/hinsen/temp/foo.scm.go > foo called with arguments: ("/home/hinsen/temp/foo.scm" "--help") > > That could be fixed at the price of a command line interface for "guix > repl" that deviates a bit from Guix conventions. For example, > is there's a file name argument, pass all arguments following it to the > script, eliminating the need for =E2=80=93. Yes, that makes sense to me. > I'll try that in a v4, and also take into account all your remaining > remarks. Just one note on the examples: > >>> +@example >>> +$ guix repl -- my-script.scm --input=3Dfoo.txt >>> +@end example >> >> I=E2=80=99d remove =E2=80=9C$=E2=80=9D from the examples. > > There are many examples in guix.texi with $, and also many without. Plus > some with # as the command line prompt. Yeah, the manual is kinda inconsistent, and I=E2=80=99m self-inconsistent to tell the truth. :-) I=E2=80=99ve come to the conclusion that snippets that contain only input s= hould be written without a prompt, for easier copy/pasting. (I=E2=80=99ve seen Python documentation where JS magic allows people to tog= gle prompt display, I find it nice.) > A technical question: is there any way to suppress the error message > about the source being newer than the cached version? This is really > annoying when running scripts. > >> hinsen@guix ~$ ~/foo.scm a b c >> ;;; note: source file /home/hinsen/temp/foo.scm >> ;;; newer than compiled /home/hinsen/.cache/guile/ccache/3.0-LE-= 8-4.2/home/hinsen/temp/foo.scm.go >> foo called with arguments: ("/home/hinsen/temp/foo.scm" "a" "b" "c") I guess ~/.cache/=E2=80=A6/*.go exists because you first ran =E2=80=9Cguile= foo.scm=E2=80=9D, no? In that case, you can simply remove that .go file. The =E2=80=98guix=E2=80=99 command turns off auto-compilation so =E2=80=98g= uix repl=E2=80=99 scripts would always be interpreted, for better or worse. Thanks, Ludo=E2=80=99.