Permalink
Browse files
Set $HOME up front, like other environment variables.
If it wasn't already set, it would be evaluated on every ~.
- Loading branch information...
Showing
with
8 additions
and
9 deletions.
-
+5
−0
core/state.py
-
+3
−9
core/word_eval.py
|
|
@@ -417,6 +417,11 @@ def _InitVarsFromEnv(self, environ): |
|
|
ast.LhsName('SHELLOPTS'), None, (var_flags_e.ReadOnly,),
|
|
|
scope_e.GlobalOnly)
|
|
|
|
|
|
v = self.GetVar('HOME')
|
|
|
if v.tag == value_e.Undef:
|
|
|
home_dir = util.GetHomeDir() or '~' # No expansion if not found?
|
|
|
SetGlobalString(self, 'HOME', home_dir)
|
|
|
|
|
|
def SetSourceLocation(self, source_name, line_num):
|
|
|
# Mutate Str() objects.
|
|
|
self.source_name.s = source_name
|
|
|
|
|
|
@@ -176,16 +176,10 @@ def _EvalTildeSub(self, prefix): |
|
|
if prefix == '':
|
|
|
# First look up the HOME var, and then env var
|
|
|
val = self.mem.GetVar('HOME')
|
|
|
if val.tag == value_e.Str:
|
|
|
return val.s
|
|
|
elif val.tag == value_e.StrArray:
|
|
|
raise AssertionError
|
|
|
|
|
|
s = util.GetHomeDir()
|
|
|
if s is None:
|
|
|
s = '~' + prefix # No expansion I guess
|
|
|
return s
|
|
|
assert val.tag == value_e.Str, val
|
|
|
return val.s
|
|
|
|
|
|
# For ~otheruser/src. TODO: Should this be cached?
|
|
|
# http://linux.die.net/man/3/getpwnam
|
|
|
try:
|
|
|
e = pwd.getpwnam(prefix)
|
|
|
|
0 comments on commit
45bdc29