Skip to content

Commit 087cc29

Browse files
authored
feat: Add new property argsString.
* feat: add new property argsString * fix: error when no argString property * refactor: wrap arguments in a function * refactor: use shell-quote to parse args array And also perform the argsString validation at extension.ts. * chore: clean changed files wrongly * chore: add execution permission to bashdb * format: delete space in import
1 parent 4958588 commit 087cc29

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

bashdb_dir/bashdb

100644100755
File mode changed.

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"dependencies": {
4949
"child-process": "^1.0.2",
5050
"npm-which": "^3.0.1",
51+
"shell-quote": "^1.7.2",
5152
"vscode-debugadapter": "1.38.0",
5253
"vscode-debugprotocol": "1.38.0"
5354
},
@@ -101,9 +102,14 @@
101102
"properties": {
102103
"args": {
103104
"// type: Array<string> -> warning `Incorrect type. Expected Array<string>` in launch.json": null,
104-
"description": "Command line arguments. (i.e. [\"--opt\", \"arg\"])",
105+
"description": "Command line arguments in array of strings format. (i.e. [\"--opt\", \"arg\"])",
105106
"default": []
106107
},
108+
"argsString": {
109+
"// type: string -> warning `Incorrect type. Expected string` in launch.json": null,
110+
"description": "Command line arguments in string format. (i.e. \"--opt arg\"]. The arguments in this string will be appended to the arguments of `args`, if present.)",
111+
"default": ""
112+
},
107113
"cwd": {
108114
"type": "string",
109115
"description": "Working directory. (i.e. `cd $cwd; bashdb <options> $program` will be executed internally).",

src/bashDebug.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import { validatePath } from './bashRuntime';
1212
import { getWSLPath, reverseWSLPath, escapeCharactersInBashdbArg, getWSLLauncherPath } from './handlePath';
1313
import { EventSource } from './eventSource';
1414
import { spawnBashScript } from './spawnBash';
15+
import { quote } from 'shell-quote'
1516

1617
export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
1718

1819
// Non-optional arguments are guaranteed to be defined in extension.ts: resolveDebugConfiguration().
20+
argsString: string;
1921
args: string[];
2022
env: object;
2123
cwd: string;
@@ -151,7 +153,7 @@ export class BashDebugSession extends LoggingDebugSession {
151153
const command = this.joinCommands(
152154
`${envVars}cd "${args.cwdEffective}"`,
153155
`while [[ ! -p "${fifo_path}" ]]; do sleep 0.25; done`,
154-
`"${args.pathBash}" "${args.pathBashdb}" --quiet --tty "${fifo_path}" --tty_in "${fifo_path}_in" --library "${args.pathBashdbLib}" -- "${args.programEffective}" ${args.args.map(e => `"` + e.replace(`"`, `\\\"`) + `"`).join(` `)}`);
156+
`"${args.pathBash}" "${args.pathBashdb}" --quiet --tty "${fifo_path}" --tty_in "${fifo_path}_in" --library "${args.pathBashdbLib}" -- "${args.programEffective}" ${quote(args.args)} ${args.argsString}`);
155157

156158
if (this.launchArgs.terminalKind === "debugConsole" || this.launchArgs.terminalKind === undefined) {
157159
spawnBashScript(

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class BashConfigurationProvider implements vscode.DebugConfigurationProvider {
8888
return vscode.window.showErrorMessage("Please specify `args` as array of strings in launch.json.").then(_ => { return undefined; });
8989
}
9090

91+
if (!config.argsString) {
92+
config.argsString = "";
93+
}
94+
9195
if (!config.env) { config.env = {}; }
9296
if (!config.cwd) {
9397
if (!folder) {

0 commit comments

Comments
 (0)