unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Winter via Guix-patches via <guix-patches@gnu.org>
To: 61927@debbugs.gnu.org
Cc: Winter <winter@winter.cafe>
Subject: [bug#61927] [PATCH 0/1] environment: Fix '--check' for shells that output ANSI escape codes based on 'TERM'.
Date: Thu,  2 Mar 2023 21:25:35 -0500	[thread overview]
Message-ID: <20230303022535.8336-1-winter@winter.cafe> (raw)

Hi,

I ran into an issue where 'guix shell --check' would fail on Debain 11's Bash, even though the environment variable it was complaining about not being set was in fact set.

As far as I can tell, the issue is caused by Bash's support for bracketed paste [0], which is causing it to output "\x1b[?2004l\r" before the script output, leading the first vhash entry to be invalid (in the sense that 'validate-child-shell-environment' will never see it).

Per ncurses' terminfo database [1], setting it to nothing (which is "unknown," per my understanding/testing with 'tput') is the same as setting it to "dumb," which will hopefully get us in the clear for the future, assuming shells play nice with regards to terminal specifications and detection.

Given this, there are a few alternative solutions that I'd like to propose:

1. Set 'TERM' to 'dumb'. This has the benefit of being explictly specified in the terminfo database, though any sane implementation should(?) fall back to it if it's set to nothing instead.
2. Use the shell non-interactively, if possible, and fall back to the script in interactive mode. We'd have to assume that the shell takes some sort of argument for a command (e.g. '-c'/'--command'), though based on the fact that we currently don't do that, I assume it's for a good reason.
3. Strip ANSI escape codes when adding the lines to the list. This might be the best one, though I'm unsure how best to do it. A PEG parser? A regex?

This was definitely an interesting issue to look into, and I look forward to thoughts on the matter.

Thanks,
Winter

P.S. I've seen a few commit prefixes that touch 'guix/scripts', like "environment" (as I've used here, since it seems to be the most prominent) and "guix: shell". Is one more correct than the other?

[0]: https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences, under "Some popular private sequences"
[1]: https://invisible-island.net/ncurses/terminfo.src.html#tic-unknown

Winter (1):
  environment: Unset 'TERM' when checking environment.

 guix/scripts/environment.scm | 2 ++
 1 file changed, 2 insertions(+)


base-commit: ea870a70e93e7ea93e35fa8e0afc3cfdb1b66ba2
-- 
2.39.1





             reply	other threads:[~2023-03-03  2:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03  2:25 Winter via Guix-patches via [this message]
2023-03-03  2:27 ` [bug#61927] [PATCH 1/1] environment: Unset 'TERM' when checking environment Winter via Guix-patches via
2023-03-13 13:21 ` bug#61927: [PATCH 0/1] environment: Fix '--check' for shells that output ANSI escape codes based on 'TERM' Ludovic Courtès

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230303022535.8336-1-winter@winter.cafe \
    --to=guix-patches@gnu.org \
    --cc=61927@debbugs.gnu.org \
    --cc=winter@winter.cafe \
    /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 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).