@@ -19,6 +19,7 @@ import {
1919} from './common/window.apis' ;
2020import { getConfiguration } from './common/workspace.apis' ;
2121import { createManagerReady } from './features/common/managerReady' ;
22+ import { identifyTerminalShell } from './features/common/shellDetector' ;
2223import { AutoFindProjects } from './features/creators/autoFindProjects' ;
2324import { ExistingProjects } from './features/creators/existingProjects' ;
2425import { NewPackageProject } from './features/creators/newPackageProject' ;
@@ -49,7 +50,7 @@ import { PythonProjectManagerImpl } from './features/projectManager';
4950import { getPythonApi , setPythonApi } from './features/pythonApi' ;
5051import { registerCompletionProvider } from './features/settings/settingCompletions' ;
5152import { setActivateMenuButtonContext } from './features/terminal/activateMenuButton' ;
52- import { normalizeShellPath } from './features/terminal/shells/common/shellUtils' ;
53+ import { getShellCommandAsString , normalizeShellPath } from './features/terminal/shells/common/shellUtils' ;
5354import {
5455 clearShellProfileCache ,
5556 createShellEnvProviders ,
@@ -435,6 +436,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
435436 commands . registerCommand ( 'python-envs.runPetInTerminal' , async ( ) => {
436437 try {
437438 const petPath = await getNativePythonToolsPath ( ) ;
439+ let command : { subcommand : string ; args ?: string [ ] } | undefined ;
438440
439441 // Show quick pick menu for PET operation selection
440442 const selectedOption = await window . showQuickPick (
@@ -467,8 +469,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
467469
468470 if ( selectedOption . label === 'Find All Environments' ) {
469471 // Run pet find --verbose
470- terminal . sendText ( `"${ petPath } " find --verbose` , true ) ;
471- traceInfo ( `Running PET find command: ${ petPath } find --verbose` ) ;
472+ command = { subcommand : 'find' , args : [ '--verbose' ] } ;
472473 } else if ( selectedOption . label === 'Resolve Environment...' ) {
473474 // Show input box for path
474475 const placeholder = isWindows ( ) ? 'C:\\path\\to\\python\\executable' : '/path/to/python/executable' ;
@@ -489,8 +490,15 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
489490 }
490491
491492 // Run pet resolve with the provided path
492- terminal . sendText ( `"${ petPath } " resolve "${ inputPath . trim ( ) } "` , true ) ;
493- traceInfo ( `Running PET resolve command: ${ petPath } resolve "${ inputPath . trim ( ) } "` ) ;
493+ command = { subcommand : 'resolve' , args : [ inputPath . trim ( ) ] } ;
494+ }
495+
496+ if ( command ) {
497+ const execString = getShellCommandAsString ( identifyTerminalShell ( terminal ) , [
498+ { executable : petPath , args : [ command . subcommand , ...( command . args || [ ] ) ] } ,
499+ ] ) ;
500+ terminal . sendText ( execString , true ) ;
501+ traceInfo ( `Running PET ${ command . subcommand } command: ${ execString } ` ) ;
494502 }
495503 } catch ( error ) {
496504 traceError ( 'Error running PET in terminal' , error ) ;
0 commit comments