unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A capture-stdout wrapper procedure in (guix build utils)?
@ 2024-04-20 22:26 Fabio Natali
  2024-04-21 15:35 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Natali @ 2024-04-20 22:26 UTC (permalink / raw)
  To: guix-devel

Hallo,

I noticed this capture-stdout wrapper procedure while reviewing Tomas'
patch 68289⁰:

,----
| (define (capture-stdout . prog+args)
|   (let* ((port (apply open-pipe* OPEN_READ prog+args))
|          (data (get-string-all port)))
|     (if (= 0 (status:exit-val (close-pipe port)))
|         (string-trim-right data #\newline)
|         (error "command failed"))))
`----

Since this seems to be a somewhat general and useful pattern, do you
think it might be worth to add it (or a variation thereof) to '(guix
build utils)'?

Thanks, best wishes, Fabio.


⁰ https://issues.guix.gnu.org/issue/68289/#0-lineno93


-- 
Fabio Natali
https://fabionatali.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A capture-stdout wrapper procedure in (guix build utils)?
  2024-04-20 22:26 A capture-stdout wrapper procedure in (guix build utils)? Fabio Natali
@ 2024-04-21 15:35 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
  2024-04-23 15:38   ` Fabio Natali
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Lechner via Development of GNU Guix and the GNU System distribution. @ 2024-04-21 15:35 UTC (permalink / raw)
  To: Fabio Natali, guix-devel

Hi Fabio,

On Sat, Apr 20 2024, Fabio Natali wrote:

> do you think it might be worth to add it (or a variation thereof) to
> '(guix build utils)'?

I use this [1] which gives the caller access to the exit status and is
also slightly shorter:

    (define (command-with-output-to-string/status* command)
      (let* ((input-pipe (apply open-pipe* OPEN_READ command))
    	 (output (get-string-all input-pipe))
    	 (exit-val (status:exit-val (close-pipe input-pipe))))
        (values output exit-val)))

It may be better, however, to finally fix Guile's 'system' and 'system*'
to work with 'with-output-to-string'. [2]

Kind regards
Felix

[1] https://codeberg.org/lechner/preambled-exec/src/commit/c5c498c3890f22cda070fe35b314f01982ebc885/test/simple-variable.scm#L28-L32
[2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43364


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A capture-stdout wrapper procedure in (guix build utils)?
  2024-04-21 15:35 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
@ 2024-04-23 15:38   ` Fabio Natali
  0 siblings, 0 replies; 3+ messages in thread
From: Fabio Natali @ 2024-04-23 15:38 UTC (permalink / raw)
  To: Felix Lechner, guix-devel

On 2024-04-21, 08:35 -0700, Felix Lechner <felix.lechner@lease-up.com> wrote:
> It may be better, however, to finally fix Guile's 'system' and
> 'system*' to work with 'with-output-to-string'. [2]

Hi Felix,

Thanks for getting back to me.

Great point re potentially fixing this further up in the "chain",
i.e. in Guile. I'll try and raise this on the Guile IRC channel and/or
ML and update this thread with my findings.

Thanks, best wishes, Fabio.


-- 
Fabio Natali
https://fabionatali.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-23 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-20 22:26 A capture-stdout wrapper procedure in (guix build utils)? Fabio Natali
2024-04-21 15:35 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2024-04-23 15:38   ` Fabio Natali

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).