problem while using substitution variables ( $VAR or ${VAR} ) in /etc/env.d enviroment is incorrectly set Reproducible: Always Steps to Reproduce: 1. make /etc/env.d/99test file with content: VAR1="variable1" VAR2="$VAR1/variable2" VAR3="${VAR1}/variable3" 2. run env-update && source /etc/profile 3. run env|grep VAR Actual Results: VAR1=variable1 VAR3=${VAR1}/variable3 VAR2=VAR1/variable2 Expected Results: VAR1=variable1 VAR3=variable1/variable3 VAR2=variable1/variable2 problem is here in env_update.py : env_keys.sort() for k in env_keys: v = env[k] if v.startswith('$') and not v.startswith('${'): outfile.write("export %s=$'%s'\n" % (k, v[1:])) else: outfile.write("export %s='%s'\n" % (k, v)) shoul be : # env_keys.sort() # <- is this really needed ? for k in env_keys: v = env[k] if v.startswith('$') and not v.startswith('${'): outfile.write("export %s=$'%s'\n" % (k, v[1:])) # <- weird, what if one use VAR2="$VAR1/dir1 $VAR1/dir2" ? else: outfile.write("export %s=\"%s\"\n" % (k, v)) # <- now it is safe to use ${VAR} in any context
It was never intended to work. Maybe you should use /etc/profile.d instead. There's some code at the bottom of /etc/profile that automatically sources /etc/profile.d/*.sh.
Closing due to age and last comment.