Rely on $PWD instead of getcwd() more often

Fixes https://github.com/fish-shell/fish-shell/issues/696
This commit is contained in:
ridiculousfish
2013-04-27 00:45:38 -07:00
parent 807c5f2ef2
commit fe6699f0bf
7 changed files with 22 additions and 30 deletions

14
env.cpp
View File

@@ -507,6 +507,20 @@ int env_set_pwd()
return 1;
}
wcstring env_get_pwd_slash(void)
{
env_var_t pwd = env_get_string(L"PWD");
if (pwd.missing_or_empty())
{
return L"";
}
if (! string_suffixes_string(L"/", pwd))
{
pwd.push_back(L'/');
}
return pwd;
}
/**
Set up default values for various variables if not defined.
*/