GNU bug report logs - #43364
Possible bug with output redirection

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: pinoaffe <pinoaffe@HIDDEN>; dated Sat, 12 Sep 2020 21:00:02 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 43364 <at> debbugs.gnu.org:


Received: (at 43364) by debbugs.gnu.org; 23 Apr 2024 16:33:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 23 12:33:30 2024
Received: from localhost ([127.0.0.1]:53175 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rzJ5A-000683-6J
	for submit <at> debbugs.gnu.org; Tue, 23 Apr 2024 12:33:30 -0400
Received: from relay2-d.mail.gandi.net ([217.70.183.194]:43215)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1rzJ52-00060x-Fa
 for 43364 <at> debbugs.gnu.org; Tue, 23 Apr 2024 12:33:20 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id E7B2740008
 for <43364 <at> debbugs.gnu.org>; Tue, 23 Apr 2024 16:32:52 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fabionatali.com;
 s=gm1; t=1713889973;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:  in-reply-to:in-reply-to; 
 bh=amLssmxvQWFf1miy30l9SU6cpbLDIOmhnLTEVovFUUQ=;
 b=e3eTiIuJg4KY+hkTGFULGnESMBwIO6nqnN+lQG+nAASjZcae/1+4e8Q5BZ1NqMKZxRzA5P
 UUyoqTpEhwcxxaUzuiQLPUHwpuW3Hc+xJjiP2xxiCj8xWZcE8lRmfyyPwHili4xqMyeMrW
 pBmUndZkxvdwfOzXknp2BIiWYfbLQb+79w8rsONTENM4r8sc3hJ6MDcuHpUWVTkSB7ZbyK
 zvGq0EViKKEZerDMFJqGjQQtEte2avVKnMpOjCkxp2LYATS7QdycE+dWHT18UGaJukVKBz
 WVTSfUGlsK9/KFePJlqaWC2gN99n/iGydBV93GlLx1+dm0+QBSHflSAO12+Vdg==
From: Fabio Natali <me@HIDDEN>
To: 43364 <at> debbugs.gnu.org
Subject: bug#43364: with-output-to-port works with file ports
In-Reply-To: CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN
Date: Tue, 23 Apr 2024 17:32:52 +0100
Message-ID: <87zftkniob.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-GND-Sasl: me@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 43364
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Dear All =F0=9F=91=8B,

I've been encountering a few times the need for a procedure like
'system' or 'system*' but that might be capable of capturing the output
of the program that's being called.

While this is something that can be solved with a simple 'open-pipe*'
wrapper, the pattern seems relatively frequent in Guix, which is where I
noticed it. I suggested that some variant of such a wrapper could be
added to '(guix build utils)'=E2=81=B0.

In reply to my post, it was brought to my attention that the problem
might be addressed at the Guile level and pointed me to this bug report.

I thought of sending a quick follow-up here to see if there's any rough
consensus on a possible way of addressing this - or why it might be
difficult or potentially not worth the effort.

Thanks, all best, Fabio.

=E2=81=B0 https://lists.gnu.org/archive/html/guix-devel/2024-04/msg00199.ht=
ml


--=20
Fabio Natali
https://fabionatali.com




Information forwarded to bug-guile@HIDDEN:
bug#43364; Package guile. Full text available.

Message received at 43364 <at> debbugs.gnu.org:


Received: (at 43364) by debbugs.gnu.org; 8 Sep 2023 19:08:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 08 15:08:45 2023
Received: from localhost ([127.0.0.1]:45630 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qegqT-0002Xw-8R
	for submit <at> debbugs.gnu.org; Fri, 08 Sep 2023 15:08:45 -0400
Received: from sender3-of-o57.zoho.com ([136.143.184.57]:21784)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rekado@HIDDEN>) id 1qegqQ-0002Xl-4L
 for 43364 <at> debbugs.gnu.org; Fri, 08 Sep 2023 15:08:43 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1694200084; cv=none; 
 d=zohomail.com; s=zohoarc; 
 b=Mz4MGjFQbIA32gRKsZqmz59ldR9GA7DVd6yQMCu515uwym6higLmrrR/uL5uFtrYwX9ntYQi4p2H5Ic5g8yQVpqF+hDh0pPRMIKtYImfOsH7ewysjbgNMnIEXGPHOApq8Pdsg6iBdlRZIaX7MZOpEGtk/T24WKV70vEbhc/W7PQ=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc; t=1694200084;
 h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To;
 bh=WNfGH6wNa8v7n8Ksqe3uL59SKjJHJaCantlv8eRkswI=; 
 b=NZaki3LekS4G1GwHUcwIoKzT9lGvCY82Hl6uGw9UpN+XHvJAkPcNGiCr3A9WAQsSNQXgO/BzBTz5kuL/S3DvUKI/wkGRx4e3a6AmsvEAqnUOX1BG0OEfJq7/jBjfnNATw6I08P841unKCC2PnpAktVUZEvbQWWZy36kpjOtcr7g=
ARC-Authentication-Results: i=1; mx.zohomail.com;
 dkim=pass  header.i=elephly.net;
 spf=pass  smtp.mailfrom=rekado@HIDDEN;
 dmarc=pass header.from=<rekado@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1694200084; 
 s=zoho; d=elephly.net; i=rekado@HIDDEN;
 h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To;
 bh=WNfGH6wNa8v7n8Ksqe3uL59SKjJHJaCantlv8eRkswI=;
 b=GK/SkiZcKOq/ABqA0TLQKBHRYqnKUOaPt0qF8PAwQyUR0qHyudEEtstuTU07CxLI
 /Kmu2rtBjHKNl1V8RMn0eWUpEPVJJQJpOMpy+O3WYODkkhHgH8NMyrkLrzMiA9xCAGV
 lwj6bFhKlz0ZPI/jXF2zcVun4PClivDXf2dGCZLw=
Received: from localhost (133-122-142-46.pool.kielnet.net [46.142.122.133]) by
 mx.zohomail.com with SMTPS id 1694200082434876.6715577442903;
 Fri, 8 Sep 2023 12:08:02 -0700 (PDT)
References: <20200912225923.5fa9504e@HIDDEN>
 <CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN>
User-agent: mu4e 1.10.5; emacs 28.2
From: Ricardo Wurmus <rekado@HIDDEN>
To: Felix Lechner <felix.lechner@HIDDEN>
Subject: Re: bug#43364: with-output-to-port works with file ports
Date: Fri, 08 Sep 2023 21:06:11 +0200
In-reply-to: <CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN>
Message-ID: <877cp05vqp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-ZohoMailClient: External
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 43364
Cc: bug-guile@HIDDEN, pinoaffe <pinoaffe@HIDDEN>, 43364 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Felix Lechner via "Bug reports for GUILE, GNU's Ubiquitous Extension Langua=
ge" <bug-guile@HIDDEN> writes:

> Hi,
>
> In an interesting (or perhaps maddening) inconsistency,
> 'with-output-to-port' captures stdout from system* here
>
> (call-with-output-file "/tmp/test.log"
>   (lambda (port)
>     (with-output-to-port
>       port
>       (lambda ()
>         (system* "mktemp" "-d")))))
>
> but 'with-output-to-string' does not do so here
>
> (with-output-to-string
>   (lambda ()
>     (system* "mktemp" "-d")))
>
> According to lloda on #guile, system* handles the redirection only
> when the current ports are file ports. Thanks for that pointer!

That=E2=80=99s correct.  I=E2=80=99ve been using the following monstrosity =
to capture
and process output.  Perhaps someone finds a prettier way?

--8<---------------cut here---------------start------------->8---
(define* (call-with-output-processor command proc #:optional capture-stderr=
?)
  "Silently execute COMMAND, a list of strings representing an
executable with its arguments, and apply PROC to every line printed to
standard output and, optionally when CAPTURE-STDERR? is #T, standard
error.  Return the exit status of COMMAND."
  ;; We can only capture a program's standard error by parameterizing
  ;; current-error-port to a *file* port before using system* or
  ;; open-pipe*.  The process will write its standard error stream to
  ;; the provided file descriptor.  Meanwhile we read from the file
  ;; descriptor (blocking) for new lines until the process exits.
  (match (socketpair PF_UNIX SOCK_STREAM 0)
    ((in . out)
     (let ((err (if capture-stderr?
                    (dup out)
                    (%make-void-port "w"))))
       (catch #true
         (lambda ()
           (let ((thread
                  (parameterize ((current-error-port err)
                                 (current-output-port out))
                    (call-with-new-thread
                     (lambda ()
                       (let ((status
                              (status:exit-val
                               (apply system* command))))
                         (close-port err)
                         (close-port out)
                         status))))))
             (let loop ()
               (match (read-line in 'concat)
                 ((? eof-object?)
                  (for-each
                   (lambda (port)
                     (false-if-exception (close-port port)))
                   (list err out in))
                  (join-thread thread))
                 (line
                  (proc line)
                  (loop))))))
         (lambda (key . args)
           (for-each
            (lambda (port)
              (false-if-exception (close-port port)))
            (list err out in))
           (apply throw key args)))))))
--8<---------------cut here---------------end--------------->8---


--=20
Ricardo




Information forwarded to bug-guile@HIDDEN:
bug#43364; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Sep 2023 19:08:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 08 15:08:49 2023
Received: from localhost ([127.0.0.1]:45633 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qegqW-0002YD-KO
	for submit <at> debbugs.gnu.org; Fri, 08 Sep 2023 15:08:49 -0400
Received: from lists.gnu.org ([2001:470:142::17]:38642)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rekado@HIDDEN>) id 1qegqV-0002Xm-1j
 for submit <at> debbugs.gnu.org; Fri, 08 Sep 2023 15:08:47 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rekado@HIDDEN>)
 id 1qegqN-0007Yt-7K
 for bug-guile@HIDDEN; Fri, 08 Sep 2023 15:08:39 -0400
Received: from sender3-of-o57.zoho.com ([136.143.184.57])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rekado@HIDDEN>)
 id 1qegqK-0000ab-Ob
 for bug-guile@HIDDEN; Fri, 08 Sep 2023 15:08:38 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1694200084; cv=none; 
 d=zohomail.com; s=zohoarc; 
 b=Mz4MGjFQbIA32gRKsZqmz59ldR9GA7DVd6yQMCu515uwym6higLmrrR/uL5uFtrYwX9ntYQi4p2H5Ic5g8yQVpqF+hDh0pPRMIKtYImfOsH7ewysjbgNMnIEXGPHOApq8Pdsg6iBdlRZIaX7MZOpEGtk/T24WKV70vEbhc/W7PQ=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc; t=1694200084;
 h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To;
 bh=WNfGH6wNa8v7n8Ksqe3uL59SKjJHJaCantlv8eRkswI=; 
 b=NZaki3LekS4G1GwHUcwIoKzT9lGvCY82Hl6uGw9UpN+XHvJAkPcNGiCr3A9WAQsSNQXgO/BzBTz5kuL/S3DvUKI/wkGRx4e3a6AmsvEAqnUOX1BG0OEfJq7/jBjfnNATw6I08P841unKCC2PnpAktVUZEvbQWWZy36kpjOtcr7g=
ARC-Authentication-Results: i=1; mx.zohomail.com;
 dkim=pass  header.i=elephly.net;
 spf=pass  smtp.mailfrom=rekado@HIDDEN;
 dmarc=pass header.from=<rekado@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1694200084; 
 s=zoho; d=elephly.net; i=rekado@HIDDEN;
 h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To;
 bh=WNfGH6wNa8v7n8Ksqe3uL59SKjJHJaCantlv8eRkswI=;
 b=GK/SkiZcKOq/ABqA0TLQKBHRYqnKUOaPt0qF8PAwQyUR0qHyudEEtstuTU07CxLI
 /Kmu2rtBjHKNl1V8RMn0eWUpEPVJJQJpOMpy+O3WYODkkhHgH8NMyrkLrzMiA9xCAGV
 lwj6bFhKlz0ZPI/jXF2zcVun4PClivDXf2dGCZLw=
Received: from localhost (133-122-142-46.pool.kielnet.net [46.142.122.133]) by
 mx.zohomail.com with SMTPS id 1694200082434876.6715577442903;
 Fri, 8 Sep 2023 12:08:02 -0700 (PDT)
References: <20200912225923.5fa9504e@HIDDEN>
 <CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN>
User-agent: mu4e 1.10.5; emacs 28.2
From: Ricardo Wurmus <rekado@HIDDEN>
To: Felix Lechner <felix.lechner@HIDDEN>
Subject: Re: bug#43364: with-output-to-port works with file ports
Date: Fri, 08 Sep 2023 21:06:11 +0200
In-reply-to: <CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN>
Message-ID: <877cp05vqp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-ZohoMailClient: External
Received-SPF: pass client-ip=136.143.184.57; envelope-from=rekado@HIDDEN;
 helo=sender3-of-o57.zoho.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
Cc: bug-guile@HIDDEN, pinoaffe <pinoaffe@HIDDEN>, 43364 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)


Felix Lechner via "Bug reports for GUILE, GNU's Ubiquitous Extension Langua=
ge" <bug-guile@HIDDEN> writes:

> Hi,
>
> In an interesting (or perhaps maddening) inconsistency,
> 'with-output-to-port' captures stdout from system* here
>
> (call-with-output-file "/tmp/test.log"
>   (lambda (port)
>     (with-output-to-port
>       port
>       (lambda ()
>         (system* "mktemp" "-d")))))
>
> but 'with-output-to-string' does not do so here
>
> (with-output-to-string
>   (lambda ()
>     (system* "mktemp" "-d")))
>
> According to lloda on #guile, system* handles the redirection only
> when the current ports are file ports. Thanks for that pointer!

That=E2=80=99s correct.  I=E2=80=99ve been using the following monstrosity =
to capture
and process output.  Perhaps someone finds a prettier way?

--8<---------------cut here---------------start------------->8---
(define* (call-with-output-processor command proc #:optional capture-stderr=
?)
  "Silently execute COMMAND, a list of strings representing an
executable with its arguments, and apply PROC to every line printed to
standard output and, optionally when CAPTURE-STDERR? is #T, standard
error.  Return the exit status of COMMAND."
  ;; We can only capture a program's standard error by parameterizing
  ;; current-error-port to a *file* port before using system* or
  ;; open-pipe*.  The process will write its standard error stream to
  ;; the provided file descriptor.  Meanwhile we read from the file
  ;; descriptor (blocking) for new lines until the process exits.
  (match (socketpair PF_UNIX SOCK_STREAM 0)
    ((in . out)
     (let ((err (if capture-stderr?
                    (dup out)
                    (%make-void-port "w"))))
       (catch #true
         (lambda ()
           (let ((thread
                  (parameterize ((current-error-port err)
                                 (current-output-port out))
                    (call-with-new-thread
                     (lambda ()
                       (let ((status
                              (status:exit-val
                               (apply system* command))))
                         (close-port err)
                         (close-port out)
                         status))))))
             (let loop ()
               (match (read-line in 'concat)
                 ((? eof-object?)
                  (for-each
                   (lambda (port)
                     (false-if-exception (close-port port)))
                   (list err out in))
                  (join-thread thread))
                 (line
                  (proc line)
                  (loop))))))
         (lambda (key . args)
           (for-each
            (lambda (port)
              (false-if-exception (close-port port)))
            (list err out in))
           (apply throw key args)))))))
--8<---------------cut here---------------end--------------->8---


--=20
Ricardo




Information forwarded to bug-guile@HIDDEN:
bug#43364; Package guile. Full text available.

Message received at 43364 <at> debbugs.gnu.org:


Received: (at 43364) by debbugs.gnu.org; 8 Sep 2023 17:53:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 08 13:53:47 2023
Received: from localhost ([127.0.0.1]:45526 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qeffv-0000de-E6
	for submit <at> debbugs.gnu.org; Fri, 08 Sep 2023 13:53:47 -0400
Received: from sail-ipv4.us-core.com ([208.82.101.137]:40652)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felix.lechner@HIDDEN>) id 1qeffr-0000dT-Um
 for 43364 <at> debbugs.gnu.org; Fri, 08 Sep 2023 13:53:46 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=2017; bh=Tn4ImZ1Pao72Wek
 bULPofSCZbMboH66wTHEFi8+l9Ds=; h=cc:to:subject:date:from;
 d=lease-up.com; b=bV9y1f3WWVWlZ6jUJlODNPTMQxlxiS3C6dOTSy6wBUcENDRUo2hq
 Mw3a8fsKb0GMe+9kwWfHTIiaARY5gtiZsl4Yuk76tNJqhqSgbACIgGXLNEdkMvHa7xpxYu
 Nee+vT/dSot3zINjAIq/xxFz6u4KKRV6HcRESFl7qh/Oam2zE=
Received: by sail-ipv4.us-core.com (OpenSMTPD) with ESMTPSA id 2956e790
 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO)
 for <43364 <at> debbugs.gnu.org>; Fri, 8 Sep 2023 17:53:39 +0000 (UTC)
Received: by mail-lj1-f170.google.com with SMTP id
 38308e7fff4ca-2b9d07a8d84so38809221fa.3
 for <43364 <at> debbugs.gnu.org>; Fri, 08 Sep 2023 10:53:38 -0700 (PDT)
X-Gm-Message-State: AOJu0YyQKa1GVAld/eAhGq0oQUEUXh8/rKaeZGfYeIjk+QHKniZ9XBk5
 NhQGys3dro1wowmtsQQmw85KpRRDzGai9VaeLMU=
X-Google-Smtp-Source: AGHT+IEHMMZ3wy2C7o9LCeUZBK2e60XJhGQCJngYBISU1sghN1CvcEeVLqM1hlGNdkFDOtSY1xImVLJl2ldHHZ6wgOI=
X-Received: by 2002:a2e:8ec1:0:b0:2bd:10ee:7d22 with SMTP id
 e1-20020a2e8ec1000000b002bd10ee7d22mr2283306ljl.51.1694195616815; Fri, 08 Sep
 2023 10:53:36 -0700 (PDT)
MIME-Version: 1.0
From: Felix Lechner <felix.lechner@HIDDEN>
Date: Fri, 8 Sep 2023 10:53:00 -0700
X-Gmail-Original-Message-ID: <CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN>
Message-ID: <CAFHYt54Bd1RXJ3rzq8d9_kAHF0FUrAFqbMzNp2zCbCjptGo2EQ@HIDDEN>
Subject: with-output-to-port works with file ports
To: 43364 <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 43364
Cc: pinoaffe <pinoaffe@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

In an interesting (or perhaps maddening) inconsistency,
'with-output-to-port' captures stdout from system* here

(call-with-output-file "/tmp/test.log"
  (lambda (port)
    (with-output-to-port
      port
      (lambda ()
        (system* "mktemp" "-d")))))

but 'with-output-to-string' does not do so here

(with-output-to-string
  (lambda ()
    (system* "mktemp" "-d")))

According to lloda on #guile, system* handles the redirection only
when the current ports are file ports. Thanks for that pointer!

Kind regards
Felix




Information forwarded to bug-guile@HIDDEN:
bug#43364; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Sep 2020 07:13:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 13 03:13:19 2020
Received: from localhost ([127.0.0.1]:49382 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kHMCN-0003A6-BS
	for submit <at> debbugs.gnu.org; Sun, 13 Sep 2020 03:13:19 -0400
Received: from lists.gnu.org ([209.51.188.17]:42654)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomas@HIDDEN>) id 1kHMCM-00039y-Fw
 for submit <at> debbugs.gnu.org; Sun, 13 Sep 2020 03:13:18 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:39208)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <tomas@HIDDEN>) id 1kHMCM-0000OC-Ao
 for bug-guile@HIDDEN; Sun, 13 Sep 2020 03:13:18 -0400
Received: from mail.tuxteam.de ([5.199.139.25]:38056)
 by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
 (Exim 4.90_1) (envelope-from <tomas@HIDDEN>) id 1kHMCK-0002Df-1s
 for bug-guile@HIDDEN; Sun, 13 Sep 2020 03:13:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de;
 s=mail; 
 h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date;
 bh=cuc2uyAnYjFxdg93sSzoqUG6XOMb3k7A6TLHhGHu85s=; 
 b=rZ2vjOoTArbaF/83jNcMQ8RFdapKZkcvyJesANUN1Z9HMiJ0TOx0F75+IsNQ0TAMy+fenu23krg7dF6sjSG33wiUzKxAaj3V63P/Jyae7x00Ute4akqiKTSrvE0p/jWIaVhN1ZZeKfBPkimAnwRcHMUQQouhzcSpyfD29Bwun0xF6+t2/pgtO4aR3i0C/UzS0y0UUoce+bEWHDYBnXVQwd7UPBd9rBtISCHag1c1cNY98voW05riGznQvNh7fw1XMJ83ffKprp4lbxBMhHw4i5y0LFxKmDLvkZiZqRm0cQzWAo6LGfDGiwG2K5BZQl5DV6UWbcbbTPhRoWgdhRzNlA==;
Received: from tomas by mail.tuxteam.de with local (Exim 4.80)
 (envelope-from <tomas@HIDDEN>) id 1kHMC6-0003tO-7K
 for bug-guile@HIDDEN; Sun, 13 Sep 2020 09:13:02 +0200
Date: Sun, 13 Sep 2020 09:13:02 +0200
To: bug-guile@HIDDEN
Subject: Re: bug#43364: Possible bug with output redirection
Message-ID: <20200913071302.GA14385@HIDDEN>
References: <20200912225923.5fa9504e@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 protocol="application/pgp-signature"; boundary="GvXjxJ+pjyke8COw"
Content-Disposition: inline
In-Reply-To: <20200912225923.5fa9504e@HIDDEN>
User-Agent: Mutt/1.5.21 (2010-09-15)
From: <tomas@HIDDEN>
Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@HIDDEN;
 helo=mail.tuxteam.de
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/13 03:13:02
X-ACL-Warn: Detected OS   = Linux 3.1-3.10 [fuzzy]
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


--GvXjxJ+pjyke8COw
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Sep 12, 2020 at 10:59:23PM +0200, pinoaffe wrote:
> Dear guilers,
>=20
> When using with-output-to-string, the output of external processes
> started using system* and the like is not redirected to the temporary
> port. As far as I can tell, it just redirects things written/displayed
> from within guile.
> This seems to be a bug, or if this is intended behaviour it might be
> beneficial to document this somewhere.

I think this is intentional (or rather: out of Guile's scope). While the
Guile process's output functions are the scope of `with-output-to-string',
the subprocess started with `system' just happens to inherit the standard
output file descriptor, which is an operating system mechanism.

No idea, for example, about what would happen under Windows or other
(more or less) operating systems.

But you are right that it can be a bit confusing. I'm not sure whether a
hint in the doc would be in place.

What do oters think?

Cheers
-- t

--GvXjxJ+pjyke8COw
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAl9dxn4ACgkQBcgs9XrR2kaCngCeLf56qrToFR9M8B/CF+dZFRAG
Cq4An3gQWPGelvZ6Yhdc1CWkSy2UYCWg
=Ho7R
-----END PGP SIGNATURE-----

--GvXjxJ+pjyke8COw--




Information forwarded to bug-guile@HIDDEN:
bug#43364; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Sep 2020 20:59:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 12 16:59:29 2020
Received: from localhost ([127.0.0.1]:49092 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kHCcL-0005IO-IY
	for submit <at> debbugs.gnu.org; Sat, 12 Sep 2020 16:59:29 -0400
Received: from lists.gnu.org ([209.51.188.17]:46258)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pinoaffe@HIDDEN>) id 1kHCcI-0005IF-QS
 for submit <at> debbugs.gnu.org; Sat, 12 Sep 2020 16:59:28 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:33292)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pinoaffe@HIDDEN>)
 id 1kHCcI-0000Qu-5N
 for bug-guile@HIDDEN; Sat, 12 Sep 2020 16:59:26 -0400
Received: from mail.cock.li ([37.120.193.124]:60756)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <pinoaffe@HIDDEN>)
 id 1kHCcF-0001F9-C6
 for bug-guile@HIDDEN; Sat, 12 Sep 2020 16:59:25 -0400
Date: Sat, 12 Sep 2020 22:59:23 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=airmail.cc; s=mail;
 t=1599944357; bh=4E8YYhRmLJnHRIkOvaSd+x79BdS7W4C15BP5HaTYa2k=;
 h=Date:From:To:Subject:From;
 b=A3INCqM88JNkxMK0LCufN3T7F2fwuEGWbWsgJW0P7oYu7tFh2ZRbCSLHDvRha2UrQ
 sWOeB4SgS1LG7VvuLrl1Yhq+/nRns4xfWLhK99vgl4bNf5qtdN+DwRnPYYYc+JcUVm
 nxfGOKJwE8firlt/ISOSe1soa/GCRaDquFtwI2d3UPMj+hvfFgJD+R3kSw6U2+ttba
 rOEJOge9Urdqo9DndjOJd38cAOJyWhzYEdxE4WzJWhRGpziaP6IXl+bRQMOpTSazIf
 ZKQ8EkYL0LlELtSJhd15s8F1a1C66rIpyysdnsnESG5uwloHAzZOzzf0kxTPxhyZvq
 REteI56Hjmg/Q==
From: pinoaffe <pinoaffe@HIDDEN>
To: bug-guile@HIDDEN
Subject: Possible bug with output redirection
Message-ID: <20200912225923.5fa9504e@HIDDEN>
X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-unknown-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Received-SPF: permerror client-ip=37.120.193.124;
 envelope-from=pinoaffe@HIDDEN; helo=mail.cock.li
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/12 16:59:18
X-ACL-Warn: Detected OS   = Linux 3.11 and newer [fuzzy]
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Dear guilers,

When using with-output-to-string, the output of external processes
started using system* and the like is not redirected to the temporary
port. As far as I can tell, it just redirects things written/displayed
from within guile.
This seems to be a bug, or if this is intended behaviour it might be
beneficial to document this somewhere.

As an example:
I'd expect snippet [0] to behave like snippet [1] and return "bar",
instead it just returns the empty string.

This probably affects other similar functions.

Pandemically,
pinoaffe

[0]:
(with-output-to-string
 (lambda ()
   (system* "echo" "bar")))

[1]:
(with-output-to-string
 (lambda ()
   (display "bar")))




Acknowledgement sent to pinoaffe <pinoaffe@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#43364; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 23 Apr 2024 16:45:00 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.