Skip to content

Commit b65b6c7

Browse files
committed
Refactor: Use stric shell env for commands
The previous code duplicated the logic to prepare the shell environment in temrinal profile and regular commands. Let's properly define the same one in both places.
1 parent a9a6698 commit b65b6c7

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

client/src/driver/BitbakeDriver.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,15 @@ export class BitbakeDriver {
4646

4747
/// Execute a command in the bitbake environment
4848
async spawnBitbakeProcess (command: string): Promise<IPty> {
49-
const { shell, script } = this.prepareCommand(command)
50-
const cwd = this.getBuildConfig('workingDirectory')
51-
const shellEnv = this.getBuildConfig('shellEnv')
49+
const { shell, shellEnv, script, workingDirectory } = this.prepareCommand(command)
5250
await this.waitForBitbakeToFinish()
53-
logger.debug(`Executing Bitbake command with ${shell} in ${cwd}: ${script}`)
51+
logger.debug(`Executing Bitbake command with ${shell} in ${workingDirectory}: ${script}`)
5452
const child = pty.spawn(
5553
shell,
5654
['-c', script],
5755
{
58-
cwd: typeof(cwd) === 'string' ? cwd : undefined,
59-
env: { ...process.env, ...(typeof shellEnv === 'object' ? shellEnv : {}) }
56+
cwd: workingDirectory,
57+
env: shellEnv
6058
}
6159
)
6260
this.bitbakeProcess = child
@@ -86,7 +84,7 @@ export class BitbakeDriver {
8684
} {
8785
const shell = process.env.SHELL ?? '/bin/sh'
8886
const tempShellEnv = this.getBuildConfig('shellEnv')
89-
const shellEnv = typeof tempShellEnv === 'object' ? tempShellEnv : {}
87+
const shellEnv = {...process.env, ...(typeof tempShellEnv === 'object' ? tempShellEnv : {}) }
9088
const script = this.composeBitbakeScript(command)
9189
const tempWorkingDirectory = this.getBuildConfig('workingDirectory')
9290
const workingDirectory = typeof tempWorkingDirectory === 'string' ? tempWorkingDirectory : '.'

client/src/ui/BitbakeTerminalProfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class BitbakeTerminalProfileProvider implements vscode.TerminalProfilePro
2929
shellPath: shell,
3030
shellArgs: ['-c', script],
3131
env: shellEnv,
32+
strictEnv: true,
3233
cwd: workingDirectory,
3334
iconPath: vscode.Uri.file(path.resolve(__dirname, '../../images/yocto-view-icon.svg'))
3435
} satisfies vscode.TerminalOptions

0 commit comments

Comments
 (0)