From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: Guix-based build tool Date: Fri, 20 Apr 2018 22:13:49 +0200 Message-ID: <87o9idtz42.fsf@elephly.net> References: <20180406220728.GA8995@thebird.nl> <87vad0ieie.fsf_-_@gnu.org> <87604r6q9t.fsf@dustycloud.org> <87efjcte6a.fsf@gnu.org> 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]:35349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAdvH-0006pf-1y for guix-devel@gnu.org; Mon, 23 Apr 2018 12:02:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAdvD-0006zO-Pu for guix-devel@gnu.org; Mon, 23 Apr 2018 12:02:35 -0400 Received: from sender-of-o51.zoho.com ([135.84.80.216]:21116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAdvD-0006yx-IT for guix-devel@gnu.org; Mon, 23 Apr 2018 12:02:31 -0400 In-reply-to: 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: Catonano Cc: guix-devel Hi Catonano, > I am experimenting with this line > > (system* "guile" "-c" "(use-modules (commonmark)) (exit ((lambda () 0)))"= ) > > If it finds the module it returns 0 > > Otherwise it returns a different number > > I copied some bits for a configure script for a Guile project instrumente= d > with the Autotools > > I could use an example of usage of "status:Exit-val" > > The Guile manual says: > > Return the exit status value, as would be set if a process ended > normally through a call to =E2=80=98exit=E2=80=99 or =E2=80=98_exit= =E2=80=99, if any, otherwise > =E2=80=98#f=E2=80=99. > > this is not enouhg for me to understand > > In which scenario is thhis function supposed to be used ? In order to do > what ? > An example would be of great help With this procedure you can obtain the return status for =E2=80=9Csystem*= =E2=80=9D. Here=E2=80=99s an example: --8<---------------cut here---------------start------------->8--- (display "Checking for commonmarl...") (let ((status (parameterize ((current-error-port (%make-void-port "w"))) (status:exit-val (system* "guile" "-c" "(begin (use-modules (commonmarl)) (exit 0))"))))) (display (if (zero? status) "Success!" "Oh no!")) (newline)) --8<---------------cut here---------------end--------------->8--- > Anyway: Is this the idiomatic way ? > > Or maybe I should use some try catch form wrapping some module loading > instruction ? > Without launching a different guile process ? There are advantages to spawning a new guile process. One is that whatever modules you may have loaded for your tool won=E2=80=99t affect the check. It=E2=80=99s possible that your tool bundles a bunch of modules, bu= t when Guile is spawned in a pure environment it won=E2=80=99t be able to loa= d these modules. You may want to fail the configure test then. On the other hand, it=E2=80=99s ugly to pass a Guile programme as a string = to system*, when you could do that instead with pure Guile. I haven=E2=80=99t thought enough about this to give a recommendation either way. -- Ricardo