From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id r2CTMdNaAWQkCgEAbAwnHQ (envelope-from ) for ; Fri, 03 Mar 2023 03:26:27 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id GC4lMNNaAWQIYAAAG6o9tA (envelope-from ) for ; Fri, 03 Mar 2023 03:26:27 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7BA947C2F for ; Fri, 3 Mar 2023 03:26:27 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=winter.cafe header.s=key1 header.b="E/ahGj6e"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677810387; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=HZ3u6vZD+BaEcsK3HdSdnE/M0Jw7PQ5FdSYPBqKnSbs=; b=UAjLfwQQgF48AIpuyzwZlJQJVy6RVIR1tz4fuWKcj1cVyyeuJ1MdRxF6lxH3xnWcuOPFuY 64EqPhfQVzQMMYSNWjjt4rcng/2tDxYN/ZVkKqNTi0/LDFmEUwv+Qp7XejWgivjVMeRPA7 qlbJlFsgLma6M9yLl3a6ROz81T+xFvLWnr+uFwi/c7UPwE64ppVABxwhmYAf1/ouLy3cOm 92XheBLca7AjIjnClP04tNfs9gpt1t1P5fmXPzwr2cNgqJfI20D/GuCxoEXNuXLV813K4Z zKqcLJqerSKvw3xWVQtxUPR8Vv0GxXWF04+SpPtDy0wlQ//vBU+dAWbbcyHi+Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=winter.cafe header.s=key1 header.b="E/ahGj6e"; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677810387; a=rsa-sha256; cv=none; b=Yx/FdhfqJ1ij3fCN8f2ys48SJuUZP6BvNUyjMEvSkflEpoiQktYi5V1eRsBxnyi7iCHr9R U8k9FK6dcgI1NqRdjiyAk4MjLapcC/d6CIgqtSibCcSmKr0YNiBTE29nJ2w9+CaGHTYDJP EZAhSNNDKF4rXtS00BRVCOV3Y2zNsHkZLjANl77UqhraPEtE5WeTre5In1qvV9bKXuhuzJ ztV1AOe+qknqbEUK7y7/Px31r10xZer7Y0WwO09yp7cMbLfglARmqDDUrWrOuiVGfWZOxL 3xNlJUN8HE8cUjHF6PP/Cu6TEmwd23pIcuBIbzYDAME+XsqX+9EuhEBsGmgExA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXv7U-0000oq-V3; Thu, 02 Mar 2023 21:26:04 -0500 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 ) id 1pXv7T-0000of-Aa for guix-patches@gnu.org; Thu, 02 Mar 2023 21:26:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXv7T-0007Oj-2W for guix-patches@gnu.org; Thu, 02 Mar 2023 21:26:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pXv7S-0002Nh-EK for guix-patches@gnu.org; Thu, 02 Mar 2023 21:26:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61927] [PATCH 0/1] environment: Fix '--check' for shells that output ANSI escape codes based on 'TERM'. Resent-From: Winter Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 03 Mar 2023 02:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61927 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61927@debbugs.gnu.org Cc: Winter X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16778103489124 (code B ref -1); Fri, 03 Mar 2023 02:26:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Mar 2023 02:25:48 +0000 Received: from localhost ([127.0.0.1]:59341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXv7D-0002N4-Sd for submit@debbugs.gnu.org; Thu, 02 Mar 2023 21:25:48 -0500 Received: from lists.gnu.org ([209.51.188.17]:60192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXv7C-0002Mx-MV for submit@debbugs.gnu.org; Thu, 02 Mar 2023 21:25:47 -0500 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 ) id 1pXv7C-0000nS-Gi for guix-patches@gnu.org; Thu, 02 Mar 2023 21:25:46 -0500 Received: from out-22.mta0.migadu.com ([2001:41d0:1004:224b::16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXv79-0007Lw-S2 for guix-patches@gnu.org; Thu, 02 Mar 2023 21:25:46 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=winter.cafe; s=key1; t=1677810339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HZ3u6vZD+BaEcsK3HdSdnE/M0Jw7PQ5FdSYPBqKnSbs=; b=E/ahGj6eSwvFhOBPDIZOwlgzlmC1MsDCYpE/TKzPb2L2r/MXMvkoBSyYH1qSOocytn0mpV vpkNKKe6oqXEHL8/B74XbRtFRQqSLUXmQkL7gtHjAZrAny7CIKtszYU0ehd1xgeFmg0Bmx /1iVhDL6lbHzi01evbU+m5pk+ejpNL7gYcuBxvmls+aEZXCCUtgqloCNQaWZasLWEUGxM0 O0hKkWgRu+2vJfebH851j7DCmgwRdUPWQy5hOlJRHJvSrehzuQP1u21RCVn8RhTzfZzqyO Tqgs0gDrGP/6XiC6LW0bqly4m+5VsYegzwTHIDjs8OJh3WLknGAfkQT/TvMBvA== Date: Thu, 2 Mar 2023 21:25:35 -0500 Message-Id: <20230303022535.8336-1-winter@winter.cafe> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:41d0:1004:224b::16; envelope-from=winter@winter.cafe; helo=out-22.mta0.migadu.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Winter X-Migadu-Spam-Score: -2.70 X-Spam-Score: -2.70 X-Migadu-Scanner: scn0.migadu.com X-Migadu-Queue-Id: 7BA947C2F X-ACL-Warn: , Winter via Guix-patches From: Winter via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: ArCLsRmw5QpO 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