From: Chris Marusich <cmmarusich@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 53355@debbugs.gnu.org, 51466@debbugs.gnu.org
Subject: bug#53355: guix shell --check: confusing error message
Date: Sun, 19 Jun 2022 13:40:50 -0700 [thread overview]
Message-ID: <87k09cpest.fsf@gmail.com> (raw)
In-Reply-To: <871qvsubgv.fsf@gnu.org> ("Ludovic Courtès"'s message of "Mon, 13 Jun 2022 12:03:28 +0200")
[-- Attachment #1.1: Type: text/plain, Size: 779 bytes --]
Hi Ludo,
Thank you for the review!
Ludovic Courtès <ludo@gnu.org> writes:
> LGTM, please push!
Before pushing, I did some more tests to make sure it was still working.
When I did this, I noticed that read-line was no longer returning
strings that end in "\r". This prevents child-shell-environment from
behaving correctly, since it incorrectly assumes that all the lines end
in "\r", stripping it off unconditionally. In the past, I'm sure
read-line was returning strings that end in "\r". I don't know what
changed, but I've attached a second patch that fixes this issue, also.
Unless you have more feedback, I'll go ahead and push both patches to
master in a few days.
--
Chris
PGP: https://savannah.gnu.org/people/viewgpg.php?user_id=106836
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-environment-Don-t-assume-that-lines-have-a-trailing-.patch --]
[-- Type: text/x-patch, Size: 2531 bytes --]
From c4fee9e63f8cb694de86ae46bd1e2e4c692eb6f6 Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
Date: Sun, 19 Jun 2022 13:16:04 -0700
Subject: [PATCH] environment: Don't assume that lines have a trailing "\r".
I've noticed that the child-shell-environment procedure is misbehaving on my
computer because the lines returned by read-line do not have a trailing "\r".
In the past, I recall that such lines did in fact have a trailing "\r". I'm
not sure why it changed, but it seems prudent to just rewrite this code to
tolerate both cases, since it seems that both cases can happen.
* guix/scripts/environment.scm (child-shell-environment) [lines]: Instead of
checking if the line exactly matches "GUIX_CHECK_DONE\r"; check if the line
begins with "GUIX_CHECK_DONE". Instead of always stripping the trailing
character from the line, only do it if the line has a trailing "\r".
---
guix/scripts/environment.scm | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index f0cb341aab..1fb4f5b7c6 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -462,13 +462,18 @@ (define lines
;; prompt from getting mixed into what we read.
(match (read-line shell-pipe-in)
((? eof-object?) (reverse lines))
- ("GUIX-CHECK-DONE\r"
+ ((? (lambda (line)
+ ;; The line might or might not have a trailing \r.
+ (string-prefix? "GUIX-CHECK-DONE" line)))
(display "done\n" port)
(reverse lines))
(line
- ;; Drop the '\r' from LINE.
- (loop (cons (string-drop-right line 1)
- lines))))))))
+ ;; Strip the trailing '\r' from LINE if present.
+ (let ((stripped-line
+ (if (string-suffix? "\r" line)
+ (string-drop-right line 1)
+ line)))
+ (loop (cons stripped-line lines)))))))))
(close-port port)
(close-port shell-pipe-in)
(waitpid pid)
--
2.34.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
next prev parent reply other threads:[~2022-06-19 20:42 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-19 3:29 bug#53355: guix shell --check: confusing error message Chris Marusich
2022-01-24 14:35 ` Ludovic Courtès
2022-01-25 0:55 ` Chris Marusich
2022-01-25 13:39 ` Ludovic Courtès
2022-02-02 7:49 ` bug#51466: " Chris Marusich
2022-02-08 9:26 ` Ludovic Courtès
2022-02-13 23:17 ` Chris Marusich
2022-02-14 9:47 ` Ludovic Courtès
2022-03-08 19:07 ` Ludovic Courtès
2022-05-20 21:37 ` Ludovic Courtès
2022-05-24 4:42 ` Chris Marusich
2022-06-13 10:03 ` Ludovic Courtès
2022-06-19 20:40 ` Chris Marusich [this message]
2022-06-20 7:34 ` bug#51466: " Ludovic Courtès
2022-06-20 10:12 ` bug#53355: " bokr
2022-06-20 17:56 ` Bengt Richter
2022-06-20 23:27 ` bug#51466: " Bengt Richter
2022-06-21 4:00 ` Thiago Jung Bauermann via Bug reports for GNU Guix
2022-06-25 9:07 ` Chris Marusich
2022-06-25 9:37 ` bug#53355: bug#51466: " Maxime Devos
2022-06-25 16:52 ` Chris Marusich
2022-06-25 17:40 ` Maxime Devos
2022-06-25 20:06 ` bug#51466: " bokr
2022-06-25 21:04 ` Maxime Devos
2022-06-26 10:33 ` Josselin Poiret via Bug reports for GNU Guix
2022-06-26 13:07 ` Maxime Devos
2022-06-26 19:45 ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2022-06-27 10:17 ` bug#51466: " Ludovic Courtès
2022-06-27 10:34 ` bug#53355: " Maxime Devos
2022-06-28 7:45 ` Ludovic Courtès
2022-06-28 10:38 ` Maxime Devos
2022-06-28 16:57 ` bug#53355: " paren--- via Bug reports for GNU Guix
2022-06-28 17:31 ` bug#51466: " Maxime Devos
2022-07-04 8:11 ` Ludovic Courtès
2022-06-27 11:23 ` bokr
2022-06-27 14:22 ` bug#51466: bug#53355: " Bengt Richter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k09cpest.fsf@gmail.com \
--to=cmmarusich@gmail.com \
--cc=51466@debbugs.gnu.org \
--cc=53355@debbugs.gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.