diff --git a/src/hatch-env-manager.ts b/src/hatch-env-manager.ts index e46c00c..dfd71c4 100644 --- a/src/hatch-env-manager.ts +++ b/src/hatch-env-manager.ts @@ -352,8 +352,13 @@ export class HatchEnvManager implements EnvironmentManager { const shellDeactivation: Map = new Map() - shellActivation.set('unknown', [ - { executable, args: [`--env=${name}`, 'shell'] }, + const args = ['--env', name, 'shell'] + shellActivation.set('unknown', [{ executable, args }]) + // PowerShell parses a leading quoted string as an expression, so a quoted + // executable path (e.g. under "C:\Program Files") must be invoked with the + // call operator `&`. A lone `&` is left unquoted by the host's quoting. + shellActivation.set('pwsh', [ + { executable: '&', args: [executable, ...args] }, ]) shellDeactivation.set('unknown', [{ executable: 'exit' }])