diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb6e843..89a96399 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs index 30f5cdc8..6e53a4fa 100644 --- a/crates/core/flags/defs.rs +++ b/crates/core/flags/defs.rs @@ -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. diff --git a/crates/core/flags/doc/man.rs b/crates/core/flags/doc/man.rs index e0ed13ba..9fa35e11 100644 --- a/crates/core/flags/doc/man.rs +++ b/crates/core/flags/doc/man.rs @@ -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.