From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id SM9TNZEjD2Q1hQAASxT56A (envelope-from ) for ; Mon, 13 Mar 2023 14:22:25 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id AEIuNZEjD2S57wAAauVa8A (envelope-from ) for ; Mon, 13 Mar 2023 14:22:25 +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 A546429B07 for ; Mon, 13 Mar 2023 14:22:25 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbi7p-0007tD-NR; Mon, 13 Mar 2023 09:22:05 -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 ) id 1pbi7m-0007se-J3 for guix-patches@gnu.org; Mon, 13 Mar 2023 09:22:02 -0400 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 1pbi7m-0006Br-B4 for guix-patches@gnu.org; Mon, 13 Mar 2023 09:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pbi7m-0004LZ-0K for guix-patches@gnu.org; Mon, 13 Mar 2023 09:22:02 -0400 Subject: bug#61927: [PATCH 0/1] environment: Fix '--check' for shells that output ANSI escape codes based on 'TERM'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-To: guix-patches@gnu.org Resent-Date: Mon, 13 Mar 2023 13:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 61927 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Winter Cc: 61927-done@debbugs.gnu.org Mail-Followup-To: 61927@debbugs.gnu.org, ludo@gnu.org, winter@winter.cafe Received: via spool by 61927-done@debbugs.gnu.org id=D61927.167871371416690 (code D ref 61927); Mon, 13 Mar 2023 13:22:01 +0000 Received: (at 61927-done) by debbugs.gnu.org; 13 Mar 2023 13:21:54 +0000 Received: from localhost ([127.0.0.1]:33895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbi7e-0004L6-EX for submit@debbugs.gnu.org; Mon, 13 Mar 2023 09:21:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58416) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbi7d-0004Ks-FT for 61927-done@debbugs.gnu.org; Mon, 13 Mar 2023 09:21:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbi7X-0006BL-IZ; Mon, 13 Mar 2023 09:21:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=0nGtewhqAmKONzjXAn9xMH/k9DENfbtW13H0q2q8RiQ=; b=KcOAoww0D0ZIfzmtZt/+ e6ZfKsJe8vXc0lH6V0fdlrDLA9IgMqpJERtpJHlW5/0qqRisDhZSGXKbcXARKaoN3OXMI+ejjeLLb Qy4+4OHlQHA0qCwjBhqixPdjl+5ENbvAMgd47gEpt5T3v7J7RfhodrsSBaQWJE8pufU9TUmcuIwIz 7+9p8FptsMNw1oB4FUCTyJmkaFMRX9Zqkcfa21kMfZFD8h/UlIx82OWcgkloAskNTZubHFy3eCZGP +lY4+4F3iRtU/so9M2KffKsLfx1ZbfIutt1UZlj2XYho78sEiL6pajgmXUA2MGcNbkSQlacZ6//S7 hxZ0rhTtyM0rhA==; Received: from [193.50.110.253] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbi7W-0003Dh-Sf; Mon, 13 Mar 2023 09:21:47 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20230303022535.8336-1-winter@winter.cafe> Date: Mon, 13 Mar 2023 14:21:44 +0100 In-Reply-To: <20230303022535.8336-1-winter@winter.cafe> (winter@winter.cafe's message of "Thu, 2 Mar 2023 21:25:35 -0500") Message-ID: <87lek03hxz.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: , 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 ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=KcOAoww0; 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=1678713745; a=rsa-sha256; cv=none; b=nwwouObjCFfbhYbzAFb9ZthhFrsPSMbs/y1bsn7nRWHOxQc4GZ5kZ4hV46gknJ2kGxj7/m Y6DfQGe8wxQDRzscJlH4GRygBv6b+Fc7Ih55Cu1vCLbK0aPS2sSl5GTRsKwon7a1ZNkhNT GYDD/sWYsrKCDPEnWXOVCz4TZlDHS4r051eaoZSJ6lcqTkmn8gZbuZFKv4JwrkQCMNNClm bZ1ACwpBQqWh2IOE2KF4gP4OzGUXSn2mHaIQO97UAPDblAITuWrz5N2BhbZ2eaoQitegD2 eref55m7ED6IXSLw9PTG6qoNbTbN1NHGPrYBpA32zV942tbpRQ6gNHQIflCiqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678713745; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=0nGtewhqAmKONzjXAn9xMH/k9DENfbtW13H0q2q8RiQ=; b=dM16prjC+FekWYb1VLVPRL8+xd3xctnqhdSgdo+AXaHCN49hus44hKhL+gaTAry4JsMpLr dpAMNGG3nN9a1I8mWtxCdjwHJ0N7HlnDUfMNOgqIYhnOfGH01v0PeJDKG+p+Wz4Ap2R2Ke VdRf89xMD7htcjyTZfU0hxZhn0Ai4TSEW9xQ5iRIS4nCYdTVEqVbJmFweQZM+IpD+w/BKK MxqwpHzVFKL8Fa53tcB84I880XuQt5KPnIMNiaCjh02bMGa9mAt1Lq0cU/htFsvjyXq41y lYBJe726H517cUrzW86UaaE3P+tgxka03yoplBPaJz+gci0SsvOWlYMmHvvKfQ== X-Migadu-Spam-Score: -4.12 X-Spam-Score: -4.12 X-Migadu-Queue-Id: A546429B07 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=KcOAoww0; 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 X-TUID: /+FEJHLnbn62 Hi Winter, Winter skribis: > 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 bei= ng set was in fact set. OK. > 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 'va= lidate-child-shell-environment' will never see it). I didn=E2=80=99t know about bracketed paste; my understanding is that it=E2= =80=99s the terminal that emits those sequences, and Bash is merely supposed to interpret them no? (E.g., Bash should make sure pasted text is not immediately executed.) Regardless, there=E2=80=99s the possibility of such escape sequences poppin= g up. > Per ncurses' terminfo database [1], setting it to nothing (which is "unkn= own," per my understanding/testing with 'tput') is the same as setting it t= o "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 propos= e: > > 1. Set 'TERM' to 'dumb'. This has the benefit of being explictly specifie= d in the terminfo database, though any sane implementation should(?) fall b= ack to it if it's set to nothing instead. > 2. Use the shell non-interactively, if possible, and fall back to the scr= ipt 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 fac= t 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? I=E2=80=99m fine with setting =E2=80=98TERM=E2=80=99 to the empty string or= to =E2=80=9Cdumb=E2=80=9D. Option #2 wouldn=E2=80=99t let us test what we want (we really want to test= an interactive shell); option #3 sounds tricky and fragile to me. So I tweaked the comment and commit log and applied your patch. Thank you for the investigation and fix! Ludo=E2=80=99.