Unsafe bc Usage #4

Open
opened 2026-02-02 14:56:58 -05:00 by jared · 0 comments
Owner

Line ~258

if (( $(echo "$reweight > 0" | bc -l 2>/dev/null || echo 0) )); then

Issue:

If bc is not installed, falls back to echo 0 which always evaluates to true

Should use bash arithmetic: if (( $(echo "$reweight > 0" | awk '{print ($1 > 0)}') ))

Or better: if $(echo "$reweight > 0.0"

# Line ~258 if (( $(echo "$reweight > 0" | bc -l 2>/dev/null || echo 0) )); then Issue: If bc is not installed, falls back to echo 0 which always evaluates to true Should use bash arithmetic: if (( $(echo "$reweight > 0" | awk '{print ($1 > 0)}') )) Or better: if [[ $(echo "$reweight > 0.0" | awk '{print ($1 > $3)}') == 1 ]]
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/driveAtlas#4