cliprobe 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/cli.js +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -220,7 +220,7 @@ In the census of the top 100 npm CLIs, 9 of 238 `--help` and `--version` runs fa
|
|
|
220
220
|
|
|
221
221
|
### ctrl-c
|
|
222
222
|
|
|
223
|
-
cliprobe lets the command run for 1 second, then sends SIGINT to its process group, which is what a terminal does when you press Ctrl-C, and gives it 3 seconds to exit. Results:
|
|
223
|
+
cliprobe lets the command run for 1 second, then sends SIGINT to its process group, which is what a terminal does when you press Ctrl-C, and gives it 3 seconds to exit. stdin is left open, as a terminal leaves it, so a server that stops at the end of stdin (`esbuild --serve`) keeps running until the Ctrl-C. Results:
|
|
224
224
|
|
|
225
225
|
| Verdict | Meaning |
|
|
226
226
|
| ------- | ---------------------------------------------------------------------------------------------- |
|
|
@@ -229,7 +229,7 @@ cliprobe lets the command run for 1 second, then sends SIGINT to its process gro
|
|
|
229
229
|
| `WARN` | Exited 0, so a script or an agent can't tell the work was interrupted |
|
|
230
230
|
| `SKIP` | Finished before the Ctrl-C, as `--version` and `--help` do: probe a command that keeps running |
|
|
231
231
|
|
|
232
|
-
A stack trace printed before the Ctrl-C doesn't count. Python's default `KeyboardInterrupt` traceback is the classic failure here, so `python3 -c 'import time; time.sleep(30)'` fails.
|
|
232
|
+
A stack trace printed before the Ctrl-C doesn't count. Python's default `KeyboardInterrupt` traceback is the classic failure here, so `python3 -c 'import time; time.sleep(30)'` fails. Across 42 watch modes, dev servers and long tasks run offline (vite, webpack, tsc, jest, Next.js, Nuxt, Astro, wrangler, nodemon and more), every one stopped within 60 ms of the Ctrl-C, whether it came after 1, 3 or 6 seconds, so the timing rarely matters. 13 of them exit 0 on purpose, among them `tsc --watch`, webpack, `next dev` and `nuxt dev`: that is a warn, not a fail.
|
|
233
233
|
|
|
234
234
|
### restore
|
|
235
235
|
|
|
@@ -302,15 +302,17 @@ if (process.stdin.isTTY) askTheQuestion();
|
|
|
302
302
|
else useTheDefault(); // or fail with a message saying which flag to pass
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
-
**ctrl-c:** Node's default already does the right thing, dying by SIGINT. If you add a handler to clean up, finish by
|
|
305
|
+
**ctrl-c:** Node's default already does the right thing, dying by SIGINT. If you add a handler to clean up, finish by dying the same way, and don't throw from it:
|
|
306
306
|
|
|
307
307
|
```js
|
|
308
308
|
process.once('SIGINT', async () => {
|
|
309
309
|
await cleanUp();
|
|
310
|
-
process.
|
|
310
|
+
process.kill(process.pid, 'SIGINT'); // the handler is gone, so this ends the process
|
|
311
311
|
});
|
|
312
312
|
```
|
|
313
313
|
|
|
314
|
+
That matters to the shell that started you: bash stops a script on Ctrl-C only when the program died by the signal. After an exit with 130 or 0, the script carries on to its next command; 130 at least stops `&&` chains and `set -e`, which 0 doesn't.
|
|
315
|
+
|
|
314
316
|
**restore:** switch every mode back off on the way out, including after Ctrl-C. Node runs `exit` handlers on `process.exit()` but not when a signal kills it, so turn SIGINT into an exit, and in raw mode, where Ctrl-C arrives as the key `\x03`, exit on that key too:
|
|
315
317
|
|
|
316
318
|
```js
|
|
@@ -332,7 +334,7 @@ Also escape U+2028, U+2029 and the bidi controls (U+202A to U+202E, U+2066 to U+
|
|
|
332
334
|
|
|
333
335
|
## Safety
|
|
334
336
|
|
|
335
|
-
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin
|
|
337
|
+
cliprobe runs the target in your current directory without a shell, with stdin closed (`/dev/null`; the stdin and ctrl-c checks use a pipe that they never write to), a temporary `HOME`, and a minimal environment (no tokens from your shell). It still executes the program, so only probe programs you trust. By default cliprobe passes only the arguments you give, or `--version` and `--help`, or none with `--bare`; only the baseline check, when you name it, adds an unknown flag. The only input it ever sends is Ctrl-C, from the ctrl-c and restore checks, to probes you write. It kills each run's whole process group on timeout, including under a pseudo-terminal. It runs on macOS and Linux, including Alpine; the terminal checks need the `script` command, which Alpine ships in `util-linux-misc`. Windows isn't supported yet.
|
|
336
338
|
|
|
337
339
|
## Contributing
|
|
338
340
|
|
package/dist/cli.js
CHANGED
|
@@ -1197,7 +1197,8 @@ async function ctrlC(command, args) {
|
|
|
1197
1197
|
signal: {
|
|
1198
1198
|
name: "SIGINT",
|
|
1199
1199
|
afterMs: CTRL_C_DELAY_MS
|
|
1200
|
-
}
|
|
1200
|
+
},
|
|
1201
|
+
stdin: "open"
|
|
1201
1202
|
});
|
|
1202
1203
|
const sent = r.signalSentMs;
|
|
1203
1204
|
return {
|
|
@@ -1932,10 +1933,11 @@ Checks:
|
|
|
1932
1933
|
as agents and CI runners often leave it. Fails if --version or
|
|
1933
1934
|
--help waits for input; for your own probes, warns if it
|
|
1934
1935
|
prompts and skips if it reads stdin like a filter.
|
|
1935
|
-
ctrl-c Sends Ctrl-C (SIGINT) after 1 s
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1936
|
+
ctrl-c Sends Ctrl-C (SIGINT) after 1 s, with stdin left open as in a
|
|
1937
|
+
terminal. Fails if the command is still running 3 s later or
|
|
1938
|
+
prints a stack trace; warns if it exits 0. Skipped when the
|
|
1939
|
+
command finishes first, so probe a command that keeps running
|
|
1940
|
+
(a watcher, a server, a long task).
|
|
1939
1941
|
restore Runs the command under a terminal and, for your own probes,
|
|
1940
1942
|
types Ctrl-C after 1 s, as a person would. Warns if it leaves
|
|
1941
1943
|
the cursor hidden, the alternate screen, mouse or focus
|
|
@@ -1973,8 +1975,8 @@ Options:
|
|
|
1973
1975
|
|
|
1974
1976
|
Exit codes: 0 no failures, 1 a check failed, 2 usage error or could not run.
|
|
1975
1977
|
Runs the target in the current directory without a shell, with stdin closed
|
|
1976
|
-
(the stdin
|
|
1977
|
-
minimal environment. Only run programs you trust.`;
|
|
1978
|
+
(the stdin and ctrl-c checks use a pipe they never write to), a temporary HOME
|
|
1979
|
+
and a minimal environment. Only run programs you trust.`;
|
|
1978
1980
|
// src/cli/program.ts
|
|
1979
1981
|
/** 0 no failures, 1 a check failed, 2 nothing could be judged because something could not run. */
|
|
1980
1982
|
function exitCodeFor(results) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cliprobe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Black-box test any command-line program for terminal-edge bugs: crashes on a closed pipe (| head), color and control codes leaking into pipes, hangs waiting on stdin, broken Ctrl-C handling, a terminal left broken after Ctrl-C, and control characters from file names reaching your terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|