Gentoo Archives: gentoo-dev

From: Renat Golubchyk <RAGermany@×××.net>
To: gentoo-dev <gentoo-dev@g.o>
Subject: [gentoo-dev] Some environment variables lost after reboot
Date: Sat, 15 Mar 2003 01:25:58

I'm a Gentoo newbie (a couple of years of Linux experience though).
Since I just made a clean stage1 install I have to configure my
system. And the first thing I did have brought me some annoying

Particularly, I modified the LESS variable in /etc/env.d/70less so I
have some info displayed. And then I did env-update which updated my
/etc/profile.env. After reboot though profile.env lacked the changes I
made (LESS wasn't there). So I did env-update again and it updated
profile.env just fine. But after every reboot LESS was gone again.

After some hours I found out that the problem was caused by
/sbin/ script that was called on reboot from 'bootmisc'
in runlevel 'boot' (when it says "Updating environment"). After some
debugging I found out that, when parses the files in
/etc/env.d it creates a list of variables it founds. But every name is
only once in the list so it knows what to write to profile.env .

The ambiguity check is pretty simple: the first match of current
variable is deleted from the list of already known variables and the
resulting list is compared to the original list. If they are equal
then we have a new variable, if they are not equal then we have found
an already known variable.

Now to my problem. In /etc/env.d/00basic there is a variable called
LESSOPEN. My LESS variable is in 70less so it is parsed later. While was making check on LESS it simply deleted LESS from
LESSOPEN because LESSOPEN already was in the list. It means that doesn't check for whole words but only for substrings
(env-update _does_ look for words).

I don't think this is a serious bug, since everybody can just change
the 'bootmisc' script to call env-update instead. But env-update is
written in python and needs more time to do the same job
( is in bash). I don't whether I should file a bug
report, but I didn't find anything similar in the bug database.

So here is the patch (or in the attachment):
========================= patch starts here =========================
---     2003-03-14 02:06:07.000000000 +0100
+++ 2003-03-15 01:09:15.000000000 +0100
@@ -52,14 +52,14 @@
                        (/bin/awk '!/^#|^\t+#/ { gsub ( /=/, "\t" ) ; print $0 }' ${x}) | \
                                while read -r variable value
-                               if [ "$(eval echo \${VARLIST/${variable}/})" = "${VARLIST}" -a \
+                               if [ "$(eval echo \${VARLIST/ ${variable} /})" = "$(eval echo \${VARLIST/# /})" -a \
                                     -n "${variable}" -a -n "${value}" ]
                                        if [ -n "${VARLIST}" ]
-                                               VARLIST="${VARLIST} ${variable}"
+                                               VARLIST="${VARLIST} ${variable} "
-                                               VARLIST="${variable}"
+                                               VARLIST=" ${variable} "
                                        echo "${VARLIST}" >${svcdir}/varlist
========================= patch ends here =========================

Did anybody experience this behavior?


Don't worry. Be hippy.


File name MIME type
rc-envupdate.patch application/octet-stream