From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tobias Geerinckx-Rice Subject: Re: [PATCH] Read /etc/environment first to allow changing environment from user profile Date: Wed, 27 Jul 2016 18:02:15 +0200 Message-ID: References: <7t60rrmf9j.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSRId-0000Ga-8d for guix-devel@gnu.org; Wed, 27 Jul 2016 12:03:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSRIa-0004Z9-Nv for guix-devel@gnu.org; Wed, 27 Jul 2016 12:03:10 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:41104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSRIa-0004XV-Hq for guix-devel@gnu.org; Wed, 27 Jul 2016 12:03:08 -0400 In-Reply-To: <7t60rrmf9j.fsf@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: =?UTF-8?Q?Carlos_S=c3=a1nchez_de_La_Lama?= Cc: guix-devel@gnu.org Carlos, On 27/07/2016 14:34, Carlos Sánchez de La Lama wrote: > I attach the proposed patch (just a change of order in /etc/profile). As > 'cat' and 'cut' are most surely available at system-level, it should not > be dangerous to use them before setting up the user profile. That's a valid point, but this should be doable in pure shell. It might even be faster (untested), and avoids needless forking. Most importantly, it's fun. > . /etc/environment > export `cat /etc/environment | cut -d= -f1` ‘cat file | ...’ can be replaced with ‘... < file’; ‘cut’ isn't needed since export accepts ‘VAR[=value]’ arguments[1][2]. You've just imported ‘/etc/environment’ on the previous line, and the values haven't been modified. Hence, the two lines above can be written as: while read line; do export "$line"; done < /etc/environment I don't know if Guix even cares about non-bash shells, but this should™ work in all POSIX®-compliant ones[4]. It's also more readable. Thoughts? Gotchas? Kind regards, T G-R [1]: http://pubs.opengroup.org/onlinepubs/009696799/utilities/export.html [2]: even if it didn't, section 2.6.2 of [3] has got you covered [3]: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html [4]: which reminds me to finish packaging ash for Guix