diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs index b49d1c606..9326ea379 100644 --- a/src/uu/csplit/src/patterns.rs +++ b/src/uu/csplit/src/patterns.rs @@ -106,7 +106,7 @@ pub fn get_patterns(args: &[String]) -> Result, CsplitError> { fn extract_patterns(args: &[String]) -> Result, CsplitError> { let mut patterns = Vec::with_capacity(args.len()); let to_match_reg = - Regex::new(r"^(/(?P.+)/|%(?P.+)%)(?P[\+-]?\d+)?$").unwrap(); + Regex::new(r"^(/(?P.+)/|%(?P.+)%)(?P[\+-]?[0-9]+)?$").unwrap(); let execute_ntimes_reg = Regex::new(r"^\{(?P[0-9]+)|\*\}$").unwrap(); let mut iter = args.iter().peekable(); diff --git a/tests/by-util/test_csplit.rs b/tests/by-util/test_csplit.rs index 2a94c10bf..96322e444 100644 --- a/tests/by-util/test_csplit.rs +++ b/tests/by-util/test_csplit.rs @@ -176,6 +176,15 @@ fn test_up_to_match_offset_repeat_twice() { assert_eq!(at.read("xx03"), generate(32, 51)); } +#[test] +fn test_up_to_match_non_ascii_offset() { + // we use a different error message than GNU + new_ucmd!() + .args(&["numbers50.txt", "/9$/𝟚"]) + .fails() + .stderr_contains("invalid pattern"); +} + #[test] fn test_up_to_match_negative_offset() { let (at, mut ucmd) = at_and_ucmd!();