Skip to content

Commit

Permalink
fix: regression for handling whitespaces in args (#70)
Browse files Browse the repository at this point in the history
We fix a regression for the handling of whitespaces in command
arguments. According to the documentation for `spawn`, the arguments
don't need to be enquoted beforehand, and doing so actually breaks the
support for whitespaces.
  • Loading branch information
P403n1x87 authored Oct 20, 2024
1 parent e467d1c commit e972db0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [0.17.3]

- - Fixed regression for support for paths with spaces in Austin tasks.

## [0.17.2]

- Fixed the heat map visualisation when using the MOJO binary format with
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Austin VS Code",
"publisher": "p403n1x87",
"description": "Austin extension for VS Code",
"version": "0.17.2",
"version": "0.17.3",
"engines": {
"vscode": "^1.57.0"
},
Expand Down
10 changes: 8 additions & 2 deletions src/providers/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import { clearDecorations, setLinesHeat } from "../view";

import { DotenvPopulateInput, config } from "dotenv";


function maybeEnquote(arg: string): string {
return arg.indexOf(' ') >= 0 ? `"${arg}"` : arg;
}


function resolveArgs(args: string[]): string[] {
const resolvedArgs: string[] = [];
args.forEach((arg) => {
Expand Down Expand Up @@ -83,8 +89,8 @@ export class AustinCommandExecutor implements vscode.Pseudoterminal {
"cwd": this.cwd,
"env": env,
}); // NOSONAR
const args = resolvedArgs.join(' ');
this.writeEmitter.fire(`Running '${this.command.cmd}' with args '${args}'.\r\n`);
const args = resolvedArgs.map(maybeEnquote).join(' ');
this.writeEmitter.fire(`Running '${maybeEnquote(this.command.cmd)}' with args '${args}'.\r\n`);
if (!this.fileName) {
this.fileName = `${this.command.cmd} ${args}`;
}
Expand Down
12 changes: 4 additions & 8 deletions src/utils/commandFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { AustinMode } from '../types';
import { getConfiguredInterpreter } from './pythonExtension';


function maybeEnquote(arg: string): string {
return arg.indexOf(' ') >= 0 ? `"${arg}"` : arg;
}

export interface AustinCommandArguments {
cmd: string
args: string[]
Expand Down Expand Up @@ -44,13 +40,13 @@ export function getAustinCommand(
if (settings.binaryMode) { _args.push("-b"); }
if (austinArgs) { _args = _args.concat(austinArgs); }
if (pythonFile) {
_args.push(maybeEnquote(getConfiguredInterpreter()));
_args.push(maybeEnquote(pythonFile));
_args.push(getConfiguredInterpreter());
_args.push(pythonFile);
}
if (pythonArgs) { _args = _args.concat(pythonArgs.map(maybeEnquote)); }
if (pythonArgs) { _args = _args.concat(pythonArgs); }

return {
cmd: maybeEnquote(cmd),
cmd: cmd,
args: _args,
envFile: envFile
};
Expand Down

0 comments on commit e972db0

Please sign in to comment.