From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 03 05:58:47 2020 Received: (at 23118) by debbugs.gnu.org; 3 Dec 2020 10:58:47 +0000 Received: from localhost ([127.0.0.1]:38595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkmJy-0003Ox-Op for submit@debbugs.gnu.org; Thu, 03 Dec 2020 05:58:47 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:48330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkmJw-0003On-Os for 23118@debbugs.gnu.org; Thu, 03 Dec 2020 05:58:45 -0500 Received: from nijino.local (217-149-166-73.nat.highway.telekom.at [217.149.166.73]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4Cmt9r2rp4z1LBCr; Thu, 3 Dec 2020 11:58:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4Cmt9r2rp4z1LBCr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1606993120; bh=iZ2WKAiQU19E+L7RSufjHCuqwyDyfbFA2vNDqiAhhm8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=A3ek2Bqw4NvSYh2rvLFxiKLlCBl2vvoaw1k/lRrpBBQ7vBjWPVZMlS3o5/Oc4lNgD SAT5raxJexBlQunCX2NRf3Jo/RNez3BQa1q+7ypdVZWKNJcl6ydmgXk0jbyO9qnCPx bBQnT7jMwkoRQm8pPjfzRG+ThtyC8n/8fYhZP4Bo= Message-ID: <6ca9bc2b5bb96b0ea6740c3412d6aa4379d553e9.camel@student.tugraz.at> Subject: Re: Duplicate entries in various environment variables From: Leo Prikler To: Chris Marusich Date: Thu, 03 Dec 2020 11:58:39 +0100 In-Reply-To: <874mbt28k4.fsf@gmail.com> References: <874mbt28k4.fsf@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 23118 Cc: 23118@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello, Chris Am Freitag, den 25.03.2016, 20:59 -0700 schrieb Chris Marusich: > Hi, > > I've noticed that my environment variables contain duplicate > (sometimes > more) entries. This occurs regardless of whether the user logs in > directly via a tty or via a desktop environment like GNOME. > > [...] > > As you can see, there are some environment variables with up to 9 > duplicate entries. Is this expected? Is it a problem? Why is it > happening? Assuming that it is not expected and that it is a > problem, > how can we prevent it from happening? It has been pointed out, that this is somewhat expected when wrapping the same environment variable multiple times. For instance, you as a GNOME user might already have gtk+ in your GTK path if you run GNOME, but GNOME applications can not rely on that and thus need to add their own. As the number of software components, that use it increases, so does the number of mentions. In the special case of gnome-terminal, this is user-visible by printing out env, but other applications get launched in a similar manner all the time without you noticing. Perhaps one could patch GNOME terminal to clear those variables before spawning the shell, but that's going to be a bit fiddly. Alternatively, one could enforce GTK_PATH by using "=" instead of prefix. More generally, this can become an issue when environment variables reach a certain size (and has led to bug reports in Guix before, which have since been fixed). POSIX mandates a syntax, that would allow removing already present components first (see [1]), but I can hardly imagine what monstrosities we would need to cook up to do this reliably. Not to mention, that some otherwise POSIX-compliant shells might not implement that syntax (correctly). Regards, Leo [1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02