1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Replace backtick quoting

This commit is contained in:
Jan Verbeek 2021-09-07 20:15:30 +02:00
parent 918603909b
commit 1ef2574b08
4 changed files with 10 additions and 10 deletions

View file

@ -150,7 +150,7 @@ fn set_context(root: &Path, options: &clap::ArgMatches) {
Some(u) => { Some(u) => {
let s: Vec<&str> = u.split(':').collect(); let s: Vec<&str> = u.split(':').collect();
if s.len() != 2 || s.iter().any(|&spec| spec.is_empty()) { if s.len() != 2 || s.iter().any(|&spec| spec.is_empty()) {
crash!(1, "invalid userspec: `{}`", u) crash!(1, "invalid userspec: {}", u.quote())
}; };
s s
} }

View file

@ -133,7 +133,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
fmt_opts.width = match s.parse::<usize>() { fmt_opts.width = match s.parse::<usize>() {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
crash!(1, "Invalid WIDTH specification: `{}': {}", s, e); crash!(1, "Invalid WIDTH specification: {}: {}", s.quote(), e);
} }
}; };
if fmt_opts.width > MAX_WIDTH { if fmt_opts.width > MAX_WIDTH {
@ -150,7 +150,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
fmt_opts.goal = match s.parse::<usize>() { fmt_opts.goal = match s.parse::<usize>() {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
crash!(1, "Invalid GOAL specification: `{}': {}", s, e); crash!(1, "Invalid GOAL specification: {}: {}", s.quote(), e);
} }
}; };
if !matches.is_present(OPT_WIDTH) { if !matches.is_present(OPT_WIDTH) {
@ -164,7 +164,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
fmt_opts.tabwidth = match s.parse::<usize>() { fmt_opts.tabwidth = match s.parse::<usize>() {
Ok(t) => t, Ok(t) => t,
Err(e) => { Err(e) => {
crash!(1, "Invalid TABWIDTH specification: `{}': {}", s, e); crash!(1, "Invalid TABWIDTH specification: {}: {}", s.quote(), e);
} }
}; };
}; };

View file

@ -767,19 +767,19 @@ impl KeyPosition {
let field = field_and_char let field = field_and_char
.next() .next()
.ok_or_else(|| format!("invalid key `{}`", key))?; .ok_or_else(|| format!("invalid key {}", key.quote()))?;
let char = field_and_char.next(); let char = field_and_char.next();
let field = field let field = field
.parse() .parse()
.map_err(|e| format!("failed to parse field index `{}`: {}", field, e))?; .map_err(|e| format!("failed to parse field index {}: {}", field.quote(), e))?;
if field == 0 { if field == 0 {
return Err("field index can not be 0".to_string()); return Err("field index can not be 0".to_string());
} }
let char = char.map_or(Ok(default_char_index), |char| { let char = char.map_or(Ok(default_char_index), |char| {
char.parse() char.parse()
.map_err(|e| format!("failed to parse character index `{}`: {}", char, e)) .map_err(|e| format!("failed to parse character index {}: {}", char.quote(), e))
})?; })?;
Ok(Self { Ok(Self {
@ -890,7 +890,7 @@ impl FieldSelector {
'R' => key_settings.set_sort_mode(SortMode::Random)?, 'R' => key_settings.set_sort_mode(SortMode::Random)?,
'r' => key_settings.reverse = true, 'r' => key_settings.reverse = true,
'V' => key_settings.set_sort_mode(SortMode::Version)?, 'V' => key_settings.set_sort_mode(SortMode::Version)?,
c => return Err(format!("invalid option: `{}`", c)), c => return Err(format!("invalid option: '{}'", c)),
} }
} }
Ok(ignore_blanks) Ok(ignore_blanks)

View file

@ -531,7 +531,7 @@ fn test_keys_invalid_field() {
new_ucmd!() new_ucmd!()
.args(&["-k", "1."]) .args(&["-k", "1."])
.fails() .fails()
.stderr_only("sort: failed to parse key '1.': failed to parse character index ``: cannot parse integer from empty string"); .stderr_only("sort: failed to parse key '1.': failed to parse character index '': cannot parse integer from empty string");
} }
#[test] #[test]
@ -539,7 +539,7 @@ fn test_keys_invalid_field_option() {
new_ucmd!() new_ucmd!()
.args(&["-k", "1.1x"]) .args(&["-k", "1.1x"])
.fails() .fails()
.stderr_only("sort: failed to parse key '1.1x': invalid option: `x`"); .stderr_only("sort: failed to parse key '1.1x': invalid option: 'x'");
} }
#[test] #[test]