ripgrep: better --path-separator error message

This commit improves the error message when --path-separator fails. Namely,
it prints the separator it got and also prints a notice for Windows users
for common failure modes.

Fixes #957
This commit is contained in:
Andrew Gallant
2018-07-22 09:32:31 -04:00
parent 7a44cad599
commit b9c922be53
3 changed files with 19 additions and 2 deletions

View File

@@ -11,6 +11,15 @@ enum State {
Literal,
}
/// Escapes an arbitrary byte slice such that it can be presented as a human
/// readable string.
pub fn escape(bytes: &[u8]) -> String {
use std::ascii::escape_default;
let escaped = bytes.iter().flat_map(|&b| escape_default(b)).collect();
String::from_utf8(escaped).unwrap()
}
/// Unescapes a string given on the command line. It supports a limited set of
/// escape sequences:
///