Skip to content

Commit be7b126

Browse files
committed
fix(approvals): unwrap only exact shell names and unexpandable words
1 parent 374bae8 commit be7b126

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎packages/client-runtime/src/work-log/commandLabel.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ describe("approvalCommandDisplayText", () => {
513513
[`/bin/bash -lc "rg -g '*.ts' TODO"`, "rg -g '*.ts' TODO"],
514514
[`bash -lc "echo $HOME"`, `bash -lc "echo $HOME"`],
515515
["/bin/bash -lc pwd", "pwd"],
516+
["/tmp/delete.sh -c 'pwd'", "/tmp/delete.sh -c 'pwd'"],
517+
["bash -c {echo,MARKER}", "bash -c {echo,MARKER}"],
518+
["bash -c *.sh", "bash -c *.sh"],
519+
["bash -c ~", "bash -c ~"],
516520
["git status", "git status"],
517521
])("unwraps only a bare shell wrapper: %s", (input, expected) => {
518522
expect(approvalCommandDisplayText(input)).toBe(expected);

‎packages/client-runtime/src/work-log/commandLabel.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,10 +1383,10 @@ export function commandDisplayText(command: string): string {
13831383
}
13841384

13851385
// `<shell> -c` or `-lc` with one literal script: single-quoted, double-quoted
1386-
// without expansions or escapes, or a plain word. Anything else around it,
1386+
// without expansions or escapes, or a word with nothing to expand. Anything else,
13871387
// such as options or redirects, keeps the whole invocation visible.
13881388
const BARE_SHELL_WRAPPER =
1389-
/^(?:\/[\w.-]+)*\/?(?:sh|bash|zsh|dash|ash|ksh|fish) -l?c (?:'([^']*)'|"([^"\\$`]*)"|([^\s'"\\$`;&|<>()]+))$/u;
1389+
/^(?:(?:\/[\w.-]+)*\/)?(?:sh|bash|zsh|dash|ash|ksh|fish) -l?c (?:'([^']*)'|"([^"\\$`]*)"|([\w./:@=+%,-]+))$/u;
13901390

13911391
/** The command an approval asks about, unwrapped only when nothing else can run. */
13921392
export function approvalCommandDisplayText(command: string): string {

0 commit comments

Comments
 (0)