From ee721ebf4e4288fc83a3fab3c26bd5a8d2bc6d0e Mon Sep 17 00:00:00 2001 From: snobee Date: Wed, 2 Feb 2022 21:22:28 -0800 Subject: [PATCH] head: handle multibyte numeric utf-8 chars --- src/uu/head/src/parse.rs | 2 +- tests/by-util/test_head.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 3f1d8ef42..b44a8b69d 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -20,7 +20,7 @@ pub fn parse_obsolete(src: &str) -> Option let mut has_num = false; let mut last_char = 0 as char; for (n, c) in &mut chars { - if c.is_numeric() { + if c.is_digit(10) { has_num = true; num_end = n; } else { diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 246f5b62a..25410d76f 100644 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -306,6 +306,10 @@ fn test_head_invalid_num() { )); } } + new_ucmd!() + .args(&["-c", "-³"]) + .fails() + .stderr_is("head: invalid number of bytes: '³'"); } #[test]