Skip to content

Add --glob-pipe to pipe in the files to work on to close #711 - #774

Merged
mathiasrw merged 6 commits into
mainfrom
fix/711
Oct 23, 2026
Merged

mathiasrw merged 6 commits into
mainfrom
fix/711

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #711

Stacked on #773.

Change

  • --glob-pipe (-g): each line of the piped data is a path or a glob of the files to work on. The lines are used together with the arguments, in the same way: a line that is an existing file is used as it is, and the rest are globbed as one pool (so ! works).
  • Line breaks can be \n or \r\n. Empty lines are left out, and spaces are kept, as a file name can have them.
  • --null-in: the piped lines are separated by null bytes, like from find -print0 or --null-out. It needs --glob-pipe.
  • --null is now --null-out, with --null as an alias. Neither is released yet.
  • --glob-pipe with --replacement-pipe, --pipe or --js-pipe is an error in the CLI, and a panic in the engine, as the piped data can only be one thing.
  • With --glob-pipe stdin is read, also when files are given as arguments.
  • The status report has "type": "GLOBS" for the piped data.
> rexreplace 'foo' 'bar' '**/*.md' --null-out | rexreplace 'baz' 'qux' --glob-pipe --null-in

Tests

  • test/js/fix/711.test.js: lines and globs, together with arguments, a line that is a file (A file with glob characters in its name is not found, or other files are changed with it #718), !, \r\n and empty lines, spaces in names, --null-in with a line break in a name, nothing piped in, the status report and the conflicts.
  • test/cli/run.sh: --glob-pipe and -g, a chain from --null-out into --glob-pipe --null-in, and the errors for the conflicts and for --null-in without --glob-pipe.
  • test/cli/run.sh: null bytes are kept. Piped in and in a file, in place, with --output and with --output-match --null-out, the null bytes come out where they went in. This is not full binary safety: with the default utf8 encoding, bytes that are not valid UTF-8 become � when a file is changed. For binary data -e latin1 keeps every byte.

@mathiasrw
mathiasrw added this pull request to stack #777 October 23, 2026 01:54
@mathiasrw
mathiasrw force-pushed the fix/711 branch 2 times, most recently from e45733b to 2051811 Compare October 23, 2026 02:00
Base automatically changed from fix/716 to main October 23, 2026 02:01
@mathiasrw
mathiasrw merged commit fc3cd94 into main Oct 23, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/711 branch October 23, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --glob-pipe to pipe in the files to work on

1 participant