mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-17 09:02:45 +08:00
Don't inherit windows paths for $PWD
If given a windows path like `F:\foo`, this currently ends up assert()ing in path_normalize_for_cd. Instead, since these paths violate a bunch of assumptions we make, we reject them and fall back on getting $PWD via getcwd() (which should give us a nice proper unixy path). Fixes #7636. This isn't tested because it would require a system where a windowsy path passes paths_are_same_file, and on the unix systems we run our tests that's impossible as far as I can tell?
This commit is contained in:
parent
dbfd3b5c39
commit
8b133833fa
|
@ -363,9 +363,12 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
// Note we may inherit a virtual PWD that doesn't match what getcwd would return; respect that
|
||||
// if and only if it matches getcwd (#5647). Note we treat PWD as read-only so it was not set in
|
||||
// vars.
|
||||
//
|
||||
// Also reject all paths that don't start with "/", this includes windows paths like "F:\foo".
|
||||
// (see #7636)
|
||||
const char *incoming_pwd_cstr = getenv("PWD");
|
||||
wcstring incoming_pwd = incoming_pwd_cstr ? str2wcstring(incoming_pwd_cstr) : wcstring{};
|
||||
if (!incoming_pwd.empty() && paths_are_same_file(incoming_pwd, L".")) {
|
||||
if (!incoming_pwd.empty() && incoming_pwd.front() == L'/' && paths_are_same_file(incoming_pwd, L".")) {
|
||||
vars.set_one(L"PWD", ENV_EXPORT | ENV_GLOBAL, incoming_pwd);
|
||||
} else {
|
||||
vars.set_pwd_from_getcwd();
|
||||
|
|
Loading…
Reference in New Issue
Block a user