mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #5543 from pawelngei/printf-x-incorrect-exit-code-when-invalid-value
printf: Fixing incorrect exit code when passing invalid value to %x
This commit is contained in:
commit
da84583b5d
2 changed files with 14 additions and 4 deletions
|
@ -8,10 +8,11 @@
|
|||
//! formatter for unsigned and signed int subs
|
||||
//! unsigned int: %X %x (hex u64) %o (octal u64) %u (base ten u64)
|
||||
//! signed int: %i %d (both base ten i64)
|
||||
use crate::error::set_exit_code;
|
||||
use crate::features::tokenize::num_format::num_format::warn_expected_numeric;
|
||||
|
||||
use super::super::format_field::FormatField;
|
||||
use super::super::formatter::{
|
||||
get_it_at, warn_incomplete_conv, Base, FormatPrimitive, Formatter, InitialPrefix,
|
||||
};
|
||||
use super::super::formatter::{get_it_at, Base, FormatPrimitive, Formatter, InitialPrefix};
|
||||
use std::i64;
|
||||
use std::u64;
|
||||
|
||||
|
@ -112,7 +113,8 @@ impl Intf {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
warn_incomplete_conv(str_in);
|
||||
warn_expected_numeric(str_in);
|
||||
set_exit_code(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,6 +258,14 @@ fn sub_num_hex_upper() {
|
|||
.stdout_only("thirty in hex is 1E");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub_num_hex_non_numerical() {
|
||||
new_ucmd!()
|
||||
.args(&["parameters need to be numbers %X", "%194"])
|
||||
.fails()
|
||||
.code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sub_num_float() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue