diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 4d5303f5c02..74be28048d0 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -47,6 +47,19 @@ fn format_and_write( None => input_line, }; + // Return false if the input is in scientific notation + if let Some(pos) = line.iter().position(|&b| b == b'E' || b == b'e') { + if pos < line.len() - 1 { + if line[pos + 1] >= 48 && line[pos + 1] <= 57 { + let errormsg = format!( + "invalid suffix in input: '{}'", + NumfmtError::FormattingError(String::from_utf8_lossy(line).to_string()) + ); + return Err(Box::new(NumfmtError::FormattingError(errormsg))); + } + } + } + // In non-abort modes we buffer the formatted output so that on error we // can emit the original line instead. let buffer_output = !matches!(options.invalid, InvalidModes::Abort); diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index 22fa8385d19..a3ea46efcac 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -1405,7 +1405,6 @@ fn test_large_integer_precision_loss_issue_11654() { // uutils accepts scientific notation (`1e9`, `5e-3`, ...); GNU rejects it // as "invalid suffix in input". #[test] -#[ignore = "GNU compat: see uutils/coreutils#11655"] fn test_scientific_notation_rejected_by_gnu_issue_11655() { new_ucmd!() .arg("1e9")