1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-11-23 21:54:45 +02:00

man: escape all hyphens in flag names

Apparently, if we don't do this, some roff renderers with use a special
Unicode hyphen. That in turn makes searching a man page not work as one
would expect.

Fixes #3140
This commit is contained in:
Andrew Gallant
2025-09-06 14:50:22 -04:00
parent 78383de9b2
commit 74959a14cb
3 changed files with 7 additions and 5 deletions

View File

@@ -27,6 +27,8 @@ Bug fixes:
Fix a bug where ripgrep would mishandle globs that ended with a `.`.
* [BUG #3108](https://github.com/BurntSushi/ripgrep/issues/3108):
Fix a bug where `-q --files-without-match` inverted the exit code.
* [BUG #3140](https://github.com/BurntSushi/ripgrep/issues/3140):
Ensure hyphens in flag names are escaped in the roff text for the man page.
Feature enhancements:

View File

@@ -5576,9 +5576,9 @@ don't need preprocessing. For example, given the following shell script,
pdftotext "$1" -
.EE
.sp
then it is possible to use \fB\-\-pre\fP \fIpre-pdftotext\fP \fB--pre-glob
'\fP\fI*.pdf\fP\fB'\fP to make it so ripgrep only executes the
\fIpre-pdftotext\fP command on files with a \fI.pdf\fP extension.
then it is possible to use \fB\-\-pre\fP \fIpre-pdftotext\fP
\fB\-\-pre\-glob\fP '\fI*.pdf\fP' to make it so ripgrep only executes
the \fIpre-pdftotext\fP command on files with a \fI.pdf\fP extension.
.sp
Multiple \flag{pre-glob} flags may be used. Globbing rules match
\fBgitignore\fP globs. Precede a glob with a \fB!\fP to exclude it.

View File

@@ -53,7 +53,7 @@ fn generate_flag(flag: &'static dyn Flag, out: &mut String) {
write!(out, r", ");
}
let name = flag.name_long();
let name = flag.name_long().replace("-", r"\-");
write!(out, r"\fB\-\-{name}\fP");
if let Some(var) = flag.doc_variable() {
write!(out, r"=\fI{var}\fP");
@@ -71,7 +71,7 @@ fn generate_flag(flag: &'static dyn Flag, out: &mut String) {
if let Some(name) = flag.name_short() {
write!(out, r"\-{}/", char::from(name));
}
write!(out, r"\-\-{}", flag.name_long());
write!(out, r"\-\-{}", flag.name_long().replace("-", r"\-"));
out.push_str(r"\fP");
});
// Convert \flag-negate{foo} into something nicer.