From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: avoid wrapper scripts when possible Date: Sun, 05 Nov 2017 18:06:17 +0100 Message-ID: <87po8wpsdy.fsf@gnu.org> References: <87mv44gyfv.fsf@elephly.net> <9ccb6232-ded3-9399-9314-91644db7d89e@crazy-compilers.com> <87tvy9ptge.fsf@elephly.net> <65968230-bd78-dfe7-2767-c1b7b89ad748@crazy-compilers.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBONL-0004qh-5I for guix-devel@gnu.org; Sun, 05 Nov 2017 12:06:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBONJ-0001qJ-Tv for guix-devel@gnu.org; Sun, 05 Nov 2017 12:06:23 -0500 Received: from hera.aquilenet.fr ([2a01:474::1]:46421) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBONJ-0001pl-NP for guix-devel@gnu.org; Sun, 05 Nov 2017 12:06:21 -0500 In-Reply-To: <65968230-bd78-dfe7-2767-c1b7b89ad748@crazy-compilers.com> (Hartmut Goebel's message of "Sun, 5 Nov 2017 12:00:17 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Hartmut Goebel Cc: guix-devel Hi! Hartmut Goebel skribis: > answering on a mail which Ricardo CCed to me and which did not make it > to the list yet. Thus I full-quote. > > Am 04.11.2017 um 23:30 schrieb Ricardo Wurmus: >> How about this: >> >> --8<---------------cut here---------------start------------->8--- >> #!/home/rekado/.guix-profile/bin/guile --no-auto-compile >> #!# (let (($0 (car (command-line)))) (execl "/home/rekado/.guix-profile/= bin/python3" $0 $0)) >> #!/home/rekado/.guix-profile/bin/python3 >> import sys; print("hello from python: "+sys.argv[0]) >> --8<---------------cut here---------------end--------------->8--- >> >> The first two lines are Guile code, but they are also line comments in >> shell, Perl, Python, Ruby, and R. The Guile code in this example calls >> the script again as a Python script. Before doing that it can set >> environment variables, like so: >> >> --8<---------------cut here---------------start------------->8--- >> #!/home/rekado/.guix-profile/bin/guile --no-auto-compile >> #!# >> #\- (setenv "PYTHONPATH" (string-append "/gnu/store/foo:/gnu/store/bar:"= (getenv "PYTHONPATH"))) >> #\- (let (($0 (car (command-line)))) (execl "/home/rekado/.guix-profile/= bin/python3" $0 $0)) >> #!/home/rekado/.guix-profile/bin/python3 >> import sys; print("hello from python: "+sys.argv[0]) >> print(sys.path) >> --8<---------------cut here---------------end--------------->8--- >> >> Did I overlook something? Or could we use this hack to remove separate >> wrapper scripts for Perl, Python, Ruby, and R? Overall this looks good to me (with the adjustments Hartmut mentions). Now, we should have a white list of languages for which this can be done. =E2=80=98wrap-program=E2=80=99 would grab the shebang and check if t= he basename of the interpreter is in that white list. Thoughts? Ludo=E2=80=99.