File tree Expand file tree Collapse file tree
src/vs/workbench/contrib/debug/node Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -320,6 +320,7 @@ export function prepareCommand(args: DebugProtocol.RunInTerminalRequestArguments
320320 }
321321
322322 let quote : ( s : string ) => string ;
323+ let hardQuote : ( s : string ) => string ;
323324 let command = '' ;
324325
325326 switch ( shellType ) {
@@ -391,17 +392,21 @@ export function prepareCommand(args: DebugProtocol.RunInTerminalRequestArguments
391392 return ( s . indexOf ( ' ' ) >= 0 || s . indexOf ( '\\' ) >= 0 ) ? `"${ s } "` : s ;
392393 } ;
393394
395+ hardQuote = ( s : string ) => {
396+ return / [ ^ \w @ % \/ + = , . : ^ - ] / . test ( s ) ? `'${ s . replace ( / ' / g, '\'\\\'\'' ) } '` : s ;
397+ } ;
398+
394399 if ( args . cwd ) {
395- command += `cd ${ quote ( args . cwd ) } ; ` ;
400+ command += `cd ${ hardQuote ( args . cwd ) } && ` ;
396401 }
397402 if ( args . env ) {
398403 command += 'env' ;
399404 for ( let key in args . env ) {
400405 const value = args . env [ key ] ;
401406 if ( value === null ) {
402- command += ` -u " ${ key } " ` ;
407+ command += ` -u ${ hardQuote ( key ) } ` ;
403408 } else {
404- command += ` " ${ key } =${ value } " ` ;
409+ command += ` ${ hardQuote ( ` ${ key } =${ value } ` ) } ` ;
405410 }
406411 }
407412 command += ' ' ;
You can’t perform that action at this time.
0 commit comments