mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-09 22:10:09 +00:00
merge env vars case insensitively (fixes #4778)
This commit is contained in:
parent
ff4b137088
commit
5c976948dd
@ -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 */
|
/** @hidden */
|
||||||
export class Session extends BaseSession {
|
export class Session extends BaseSession {
|
||||||
private pty: PTYProxy|null = null
|
private pty: PTYProxy|null = null
|
||||||
@ -108,22 +122,18 @@ export class Session extends BaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pty) {
|
if (!pty) {
|
||||||
const env = {
|
let env = mergeEnv(
|
||||||
...process.env,
|
process.env,
|
||||||
|
{
|
||||||
TERM: 'xterm-256color',
|
TERM: 'xterm-256color',
|
||||||
TERM_PROGRAM: 'Tabby',
|
TERM_PROGRAM: 'Tabby',
|
||||||
...options.env,
|
},
|
||||||
...this.config.store.terminal.environment || {},
|
options.env,
|
||||||
}
|
this.config.store.terminal.environment || {},
|
||||||
|
)
|
||||||
|
|
||||||
if (this.hostApp.platform === Platform.Windows && this.config.store.terminal.setComSpec) {
|
if (this.hostApp.platform === Platform.Windows && this.config.store.terminal.setComSpec) {
|
||||||
for (const k of Object.keys(env)) {
|
env = mergeEnv(env, { COMSPEC: this.bootstrapData.executable })
|
||||||
if (k.toUpperCase() === 'COMSPEC') {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
||||||
delete env[k]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
env.COMSPEC = this.bootstrapData.executable
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete env['']
|
delete env['']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user