mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 11:31:15 -03:00
env: skip env lines without equal sign
Given an env like
foo
bar=baz
we would set "foo" to empty due to a typo.
The typo is pointed out by a PORTING comment.
Luckily I don't think we ever hit this case because that would mean our
parent process has a serious bug. Rust's std::env::vars_os() skips env
lines that don't contain a "=" char. This seems like a reasonable behavior
for us too. Do that.
This commit is contained in:
10
src/env.cpp
10
src/env.cpp
@@ -175,13 +175,11 @@ void set_inheriteds_ffi() {
|
||||
const wcstring key_and_val = str2wcstring(envp[i]);
|
||||
size_t eql = key_and_val.find(L'=');
|
||||
if (eql == wcstring::npos) {
|
||||
// PORTING: Should this not be key_and_val?
|
||||
inheriteds[key] = L"";
|
||||
} else {
|
||||
key.assign(key_and_val, 0, eql);
|
||||
val.assign(key_and_val, eql + 1, wcstring::npos);
|
||||
inheriteds[key] = val;
|
||||
continue;
|
||||
}
|
||||
key.assign(key_and_val, 0, eql);
|
||||
val.assign(key_and_val, eql + 1, wcstring::npos);
|
||||
inheriteds[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user