From 71448a0a9fe50e50aceb79b578f5147cb996640c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:08:59 +0000 Subject: [PATCH 1/6] Initial plan From a03d9b790668ae71f95bae80f3ca30d97c010835 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:10:45 +0000 Subject: [PATCH 2/6] Plan: add --bail as alias for --halt Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- src/cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index 06452bb2..f2789372 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -112,7 +112,7 @@ const yargs = require('yargs') .boolean('H') .describe('H', 'Halt on first error') - .alias('H', 'halt') + .alias('H', ['halt', 'bail']) .default('H', false) .boolean('d') From 1c63060080ce971baf713d8ab5adbef33a23644b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:12:27 +0000 Subject: [PATCH 3/6] Add --bail alias for --halt in CLI, docs, and tests Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- README.md | 2 +- test/cli/run.sh | 14 ++++++++++---- test/js/halt.test.js | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cd124b9c..a230036e 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ Let both `"foo 'is' bar"` and `' foo "was" bar'` become `» foo ... bar «` inde | `-E` | **`--engine`** What regex engine to use. `default` is the engine of the runtime: `V8` with Node and `JSC` (JavaScriptCore) with Bun. The engine of the other runtime can not be picked. [choices: "default", "V8", "JSC"] [default: "default"] | | `-q` | **`--quiet`** Only display errors (no other info) [boolean] | | `-Q` | **`--quiet-total`** Never display errors or info [boolean] | -| `-H` | **`--halt`** Halt on first error [boolean] [default: false] | +| `-H` | **`--halt`**, **`--bail`** Halt on first error [boolean] [default: false] | | `-d` | **`--debug`** Print debug info [boolean] | | `-€` | **`--void-euro`** Void having `€` as alias for `$` in the pattern, replacement and --exclude-re parameters (the alias is never used for globs or piped data) [boolean] | | `-§` | **`--void-section`** Void having `§` as alias for `\` in the pattern, replacement and --exclude-re parameters (the alias is never used for globs or piped data) [boolean] | diff --git a/test/cli/run.sh b/test/cli/run.sh index afd8a820..18b99269 100644 --- a/test/cli/run.sh +++ b/test/cli/run.sh @@ -96,6 +96,16 @@ assert_success "rexreplace --help" assert_failure "rexreplace o-ho" assert_failure "rexreplace -H" +# -H, --halt, --bail +reset +assert_success "rexreplace --help | grep -F -- '--bail' >/dev/null" +assert_raises "rexreplace o x nope.file --bail" 1 +assert_raises "rexreplace o x nope.file --halt" 1 +assert_raises "rexreplace o x nope.file -H" 1 +# --bail is accepted (not an unknown argument) and leaves files untouched when nothing fails +assert_success "rexreplace o x my.file --bail" +assert "cat my.file" "fxxbar" + # -o reset @@ -374,10 +384,6 @@ assert "cat your.file" 'abc123' # assert "rexreplace ??? ??? my.file -Q" "foobar" # reset -# Todo: test -H -# assert "rexreplace ??? ??? my.file -H" "foobar" -# reset - # Todo: test -d # assert "rexreplace ??? ??? my.file -d" "foobar" # reset diff --git a/test/js/halt.test.js b/test/js/halt.test.js index 2aa66a63..8c7cf381 100644 --- a/test/js/halt.test.js +++ b/test/js/halt.test.js @@ -27,6 +27,9 @@ describe('--halt', () => { expect(rr('(', 'x', {pipedData: 'foobar', halt: true}).exit).toBe(1); }); + // --bail is a CLI alias for --halt (src/cli.ts). The engine only sees the halt config key. + test.todo('--bail is an alias for --halt and is tested in test/cli/run.sh'); + describe('combined', () => { test.each(['quiet', 'quietTotal'])('with --%s it still stops', (flag) => { const result = rr('o', 'x', {includeGlob: ['nope.file'], halt: true, [flag]: true}); From 4fad5ebbf6edc09005be089dcef9f2a4bfdd4c50 Mon Sep 17 00:00:00 2001 From: Mathias Wulff Date: Tue, 13 Oct 2026 03:25:45 +1100 Subject: [PATCH 4/6] Fix alias for halt option in CLI --- src/cli.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli.ts b/src/cli.ts index f2789372..3c92ed4b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -112,7 +112,8 @@ const yargs = require('yargs') .boolean('H') .describe('H', 'Halt on first error') - .alias('H', ['halt', 'bail']) + .alias('H', 'halt') + .alias('H', 'bail') .default('H', false) .boolean('d') From 2c905e0214e8c03764243ddc33e88d68005663a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 17:08:38 +0000 Subject: [PATCH 5/6] Plan: replace bail todo with proper CLI tests Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- test/js/halt.test.js | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/test/js/halt.test.js b/test/js/halt.test.js index 8c7cf381..ab1f287b 100644 --- a/test/js/halt.test.js +++ b/test/js/halt.test.js @@ -1,7 +1,20 @@ import {describe, test, expect} from 'bun:test'; +import {spawnSync} from 'child_process'; import fs from 'fs'; +import path from 'path'; import {rr} from './helper.js'; +// --bail is a CLI alias for --halt, so these cases run the CLI itself (like test/js/fix/691.test.js). +const cli = path.join(import.meta.dir, '../../src/cli.ts'); + +function runCli(...args) { + const {stdout, stderr, status} = spawnSync(process.execPath, [cli, ...args], { + input: '', + encoding: 'utf8', + }); + return {out: stdout, err: stderr, exit: status}; +} + describe('--halt', () => { test('stops the process on the first error', () => { const result = rr('o', 'x', {includeGlob: ['nope.file'], halt: true}); @@ -27,8 +40,30 @@ describe('--halt', () => { expect(rr('(', 'x', {pipedData: 'foobar', halt: true}).exit).toBe(1); }); - // --bail is a CLI alias for --halt (src/cli.ts). The engine only sees the halt config key. - test.todo('--bail is an alias for --halt and is tested in test/cli/run.sh'); + describe('--bail alias', () => { + test('is listed in --help with --halt', () => { + const result = runCli('--help'); + expect(result.exit).toBe(0); + expect(result.out).toContain('--bail'); + expect(result.out).toMatch(/-H,\s*--halt,\s*--bail/); + }); + + test.each(['--bail', '--halt', '-H'])( + '%s stops on the first error like --halt', + (flag) => { + const result = runCli('o', 'x', 'nope.file', flag); + expect(result.err).toContain('0 files found'); + expect(result.exit).toBe(1); + } + ); + + test('--bail is accepted and changes nothing when all goes well', () => { + fs.writeFileSync('my.file', 'foobar'); + const result = runCli('o', 'x', 'my.file', '--bail'); + expect(result.exit).toBe(0); + expect(fs.readFileSync('my.file', 'utf8')).toBe('fxxbar'); + }); + }); describe('combined', () => { test.each(['quiet', 'quietTotal'])('with --%s it still stops', (flag) => { From 60fc04fe7d59396f3531b69602975dc2a01f241d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 12 Oct 2026 17:24:23 +0000 Subject: [PATCH 6/6] Format halt.test.js with prettier Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com> --- test/js/halt.test.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/js/halt.test.js b/test/js/halt.test.js index ab1f287b..df001713 100644 --- a/test/js/halt.test.js +++ b/test/js/halt.test.js @@ -48,14 +48,11 @@ describe('--halt', () => { expect(result.out).toMatch(/-H,\s*--halt,\s*--bail/); }); - test.each(['--bail', '--halt', '-H'])( - '%s stops on the first error like --halt', - (flag) => { - const result = runCli('o', 'x', 'nope.file', flag); - expect(result.err).toContain('0 files found'); - expect(result.exit).toBe(1); - } - ); + test.each(['--bail', '--halt', '-H'])('%s stops on the first error like --halt', (flag) => { + const result = runCli('o', 'x', 'nope.file', flag); + expect(result.err).toContain('0 files found'); + expect(result.exit).toBe(1); + }); test('--bail is accepted and changes nothing when all goes well', () => { fs.writeFileSync('my.file', 'foobar');