guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Read /etc/environment first to allow changing environment fr


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
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]