Skip to content

Commit 150b596

Browse files
RSS1102codex
andcommitted
fix(shell): preserve pathname expansion in scripts
Co-authored-by: GPT-5 Codex <codex@openai.com>
1 parent 5298594 commit 150b596

22 files changed

Lines changed: 661 additions & 6 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22

3+
- **Fixed** `vp run` now preserves shell pathname expansion in package scripts, so unquoted patterns such as `packages/*/src` expand before they are passed to the underlying command ([#573](https://github.com/voidzero-dev/vite-task/issues/573)).
34
- **Fixed** `vp run` no longer hangs or fails when a task leaves a process running behind it, such as a dev server or a background helper, or when one of a task's processes is killed. The run finishes as soon as the task itself does, and the files the task used are still recorded ([#544](https://github.com/voidzero-dev/vite-task/issues/544), [#675](https://github.com/voidzero-dev/vite-task/pull/675)).
45
- **Fixed** A task that reads or writes an unusually large number of files now runs to the end instead of being killed partway through. Vite+ reports the run as not cached, because it could not record every file the task used ([#533](https://github.com/voidzero-dev/vite-task/issues/533), [#675](https://github.com/voidzero-dev/vite-task/pull/675)).
56
- **Fixed** Vite+ diagnostics now display individual paths and working directories without Rust debug formatting such as quoted paths or escaped Windows backslashes ([#534](https://github.com/voidzero-dev/vite-task/pull/534)).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "package-script-glob",
3+
"private": true,
4+
"scripts": {
5+
"unquoted-glob": "vtt print packages/*/src",
6+
"and-glob": "vtt print before && vtt print packages/*/src",
7+
"quoted-glob": "vtt print \"packages/*/src\"",
8+
"nested-vt-glob": "vt run print-paths prefix packages/*/src",
9+
"nested-vt-glob-fails": "vt run fail-with-code packages/*/src",
10+
"print-paths": "vtt print",
11+
"fail-with-code": "vtt exit 23"
12+
}
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[[e2e]]
2+
name = "unquoted_glob_expands_on_unix"
3+
cfg = "unix"
4+
comment = """
5+
Unquoted pathname patterns in package scripts are executed by the platform shell, matching package-manager script semantics on Unix.
6+
"""
7+
steps = [["vt", "run", "unquoted-glob"]]
8+
9+
[[e2e]]
10+
name = "unquoted_glob_uses_cmd_semantics_on_windows"
11+
cfg = "windows"
12+
comment = """
13+
Unquoted pathname patterns in package scripts are executed by `cmd.exe` on Windows. Like package-manager scripts, `cmd.exe` leaves the pattern literal.
14+
"""
15+
steps = [["vt", "run", "unquoted-glob"]]
16+
17+
[[e2e]]
18+
name = "unquoted_glob_preserves_extra_args_on_unix"
19+
cfg = "unix"
20+
comment = """
21+
Extra arguments passed to `vt run` are shell-escaped and appended after the package script. Shell operators inside one argument must remain literal after Unix shell expansion.
22+
"""
23+
steps = [["vt", "run", "unquoted-glob", "tail && vtt exit 31"]]
24+
25+
[[e2e]]
26+
name = "unquoted_glob_preserves_extra_args_on_windows"
27+
cfg = "windows"
28+
comment = """
29+
Extra arguments passed to `vt run` are escaped for `cmd.exe` and appended after the package script. Shell operators inside one argument must remain literal.
30+
"""
31+
steps = [["vt", "run", "unquoted-glob", "tail && vtt exit 31"]]
32+
33+
[[e2e]]
34+
name = "and_list_with_glob_uses_one_shell_on_unix"
35+
cfg = "unix"
36+
comment = """
37+
If any command in an `&&` list needs pathname expansion, the complete list is kept intact for the Unix shell so ordering and short-circuit semantics are preserved.
38+
"""
39+
steps = [["vt", "run", "and-glob"]]
40+
41+
[[e2e]]
42+
name = "and_list_with_glob_uses_one_shell_on_windows"
43+
cfg = "windows"
44+
comment = """
45+
If any command in an `&&` list needs shell semantics, the complete list is kept intact for `cmd.exe`, which preserves ordering and leaves the pathname pattern literal.
46+
"""
47+
steps = [["vt", "run", "and-glob"]]
48+
49+
[[e2e]]
50+
name = "quoted_glob_stays_literal"
51+
comment = """
52+
Quoted pathname patterns remain literal instead of being expanded.
53+
"""
54+
steps = [["vt", "run", "quoted-glob"]]
55+
56+
[[e2e]]
57+
name = "nested_vt_receives_expanded_glob_on_unix"
58+
cfg = "unix"
59+
comment = """
60+
An unquoted pathname pattern in a package script that invokes nested `vt run` is expanded by the shell before the new `vt` process starts. This verifies PATH lookup and preserves both preceding extra arguments and expanded paths.
61+
"""
62+
steps = [["vt", "run", "nested-vt-glob"]]
63+
64+
[[e2e]]
65+
name = "nested_vt_receives_literal_glob_on_windows"
66+
cfg = "windows"
67+
comment = """
68+
On Windows, `cmd.exe` starts nested `vt run` through PATH and forwards the pattern literally, matching package-manager script semantics while preserving the preceding extra argument.
69+
"""
70+
steps = [["vt", "run", "nested-vt-glob"]]
71+
72+
[[e2e]]
73+
name = "nested_vt_propagates_exit_code_on_unix"
74+
cfg = "unix"
75+
comment = """
76+
The shell fallback used for an unquoted pathname pattern preserves a nested `vt run` failure exit code after Unix shell expansion.
77+
"""
78+
steps = [["vt", "run", "nested-vt-glob-fails"]]
79+
80+
[[e2e]]
81+
name = "nested_vt_propagates_exit_code_on_windows"
82+
cfg = "windows"
83+
comment = """
84+
The shell fallback used for an unquoted pathname pattern preserves a nested `vt run` failure exit code with `cmd.exe` semantics.
85+
"""
86+
steps = [["vt", "run", "nested-vt-glob-fails"]]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# and_list_with_glob_uses_one_shell_on_unix
2+
3+
If any command in an `&&` list needs pathname expansion, the complete list is kept intact for the Unix shell so ordering and short-circuit semantics are preserved.
4+
5+
## `vt run and-glob`
6+
7+
```
8+
$ vtt print before && vtt print packages/*/src ⊘ cache disabled
9+
before
10+
packages/a/src packages/b/src
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# and_list_with_glob_uses_one_shell_on_windows
2+
3+
If any command in an `&&` list needs shell semantics, the complete list is kept intact for `cmd.exe`, which preserves ordering and leaves the pathname pattern literal.
4+
5+
## `vt run and-glob`
6+
7+
```
8+
$ vtt print before && vtt print packages/*/src ⊘ cache disabled
9+
before
10+
packages/*/src
11+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# nested_vt_propagates_exit_code_on_unix
2+
3+
The shell fallback used for an unquoted pathname pattern preserves a nested `vt run` failure exit code after Unix shell expansion.
4+
5+
## `vt run nested-vt-glob-fails`
6+
7+
**Exit code:** 23
8+
9+
```
10+
$ vt run fail-with-code packages/*/src ⊘ cache disabled
11+
$ vtt exit 23 packages/a/src packages/b/src ⊘ cache disabled
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# nested_vt_propagates_exit_code_on_windows
2+
3+
The shell fallback used for an unquoted pathname pattern preserves a nested `vt run` failure exit code with `cmd.exe` semantics.
4+
5+
## `vt run nested-vt-glob-fails`
6+
7+
**Exit code:** 23
8+
9+
```
10+
$ vt run fail-with-code packages/*/src ⊘ cache disabled
11+
$ vtt exit 23 packages/*/src ⊘ cache disabled
12+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# nested_vt_receives_expanded_glob_on_unix
2+
3+
An unquoted pathname pattern in a package script that invokes nested `vt run` is expanded by the shell before the new `vt` process starts. This verifies PATH lookup and preserves both preceding extra arguments and expanded paths.
4+
5+
## `vt run nested-vt-glob`
6+
7+
```
8+
$ vt run print-paths prefix packages/*/src ⊘ cache disabled
9+
$ vtt print prefix packages/a/src packages/b/src ⊘ cache disabled
10+
prefix packages/a/src packages/b/src
11+
```

0 commit comments

Comments
 (0)