URL: <https://savannah.gnu.org/bugs/?67486>
Summary: Can't use if with two separate awk floating number comparisons Group: The GNU Bourne-Again SHell Submitter: None Submitted: Tue 09 Sep 2025 03:37:22 AM UTC Category: None Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Tue 09 Sep 2025 03:37:22 AM UTC By: Anonymous This is a crime against humanity. This probably screwed so many people over through the years. You will not get correct behavior if you use awk to compare two sets of floating numbers in an if statement as two separate awk statements. Bash will exit on non-success exit code of the first awk statement, so the if statement will be incorrectly evaluated. The solution is to either use nested ifs with only one awk per if, or to use one awk to do both comparisons, which is relatively fine. But this is really tricky to troubleshoot and debug for anyone who is not aware of this intricacy. There's gotta be a better way to a) compare floats in bash without this pitfall, b) to avoid this exit code premature termination of if statements. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?67486> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature