@@ -9,6 +9,7 @@ use clap::{Arg, ArgAction, Command};
99use libc:: PRIO_PROCESS ;
1010use std:: ffi:: OsString ;
1111use std:: io:: { Error , ErrorKind , Write } ;
12+ use std:: num:: IntErrorKind ;
1213use std:: os:: unix:: process:: CommandExt ;
1314use std:: process;
1415
@@ -23,6 +24,8 @@ pub mod options {
2324 pub static COMMAND : & str = "COMMAND" ;
2425}
2526
27+ const NICE_BOUND_NO_OVERFLOW : i32 = 50 ;
28+
2629fn is_prefix_of ( maybe_prefix : & str , target : & str , min_match : usize ) -> bool {
2730 if maybe_prefix. len ( ) < min_match || maybe_prefix. len ( ) > target. len ( ) {
2831 return false ;
@@ -126,12 +129,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
126129 }
127130 match nstr. parse :: < i32 > ( ) {
128131 Ok ( num) => num,
129- Err ( e) => {
130- return Err ( USimpleError :: new (
131- 125 ,
132- translate ! ( "nice-error-invalid-number" , "value" => nstr. clone( ) , "error" => e) ,
133- ) ) ;
134- }
132+ Err ( e) => match e. kind ( ) {
133+ IntErrorKind :: PosOverflow => NICE_BOUND_NO_OVERFLOW ,
134+ IntErrorKind :: NegOverflow => -NICE_BOUND_NO_OVERFLOW ,
135+ _ => {
136+ return Err ( USimpleError :: new (
137+ 125 ,
138+ translate ! ( "nice-error-invalid-number" , "value" => nstr. clone( ) , "error" => e) ,
139+ ) ) ;
140+ }
141+ } ,
135142 }
136143 }
137144 None => {
0 commit comments