merge env vars case insensitively (fixes #4778)

上级 ff4b1370
......@@ -81,6 +81,20 @@ export class PTYProxy {
}
}
function mergeEnv (...envs) {
const result = {}
const keyMap = {}
for (const env of envs) {
for (const [key, value] of Object.entries(env)) {
// const lookup = process.platform === 'win32' ? key.toLowerCase() : key
const lookup = key.toLowerCase()
keyMap[lookup] ??= key
result[keyMap[lookup]] = value
}
}
return result
}
/** @hidden */
export class Session extends BaseSession {
private pty: PTYProxy|null = null
......@@ -108,22 +122,18 @@ export class Session extends BaseSession {
}
if (!pty) {
const env = {
...process.env,
TERM: 'xterm-256color',
TERM_PROGRAM: 'Tabby',
...options.env,
...this.config.store.terminal.environment || {},
}
let env = mergeEnv(
process.env,
{
TERM: 'xterm-256color',
TERM_PROGRAM: 'Tabby',
},
options.env,
this.config.store.terminal.environment || {},
)
if (this.hostApp.platform === Platform.Windows && this.config.store.terminal.setComSpec) {
for (const k of Object.keys(env)) {
if (k.toUpperCase() === 'COMSPEC') {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete env[k]
}
}
env.COMSPEC = this.bootstrapData.executable
env = mergeEnv(env, { COMSPEC: this.bootstrapData.executable })
}
delete env['']
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册