Replace bc with awk for floating point comparison
Use awk BEGIN block for comparing Ceph OSD reweight values instead of bc. Awk is more universally available and the previous fallback to "echo 0" could incorrectly evaluate to true. Fixes: #4 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -486,7 +486,8 @@ for bay in $(printf '%s\n' "${!DRIVE_MAP[@]}" | grep -E '^[0-9]+$' | sort -n); d
|
||||
[[ -z "$reweight" ]] && reweight="0"
|
||||
|
||||
# Determine in/out based on reweight (1.0 = in, 0 = out)
|
||||
if (( $(echo "$reweight > 0" | bc -l 2>/dev/null || echo 0) )); then
|
||||
# Use awk for floating point comparison (more portable than bc)
|
||||
if awk "BEGIN {exit !($reweight > 0)}"; then
|
||||
in_status="in"
|
||||
else
|
||||
in_status="out"
|
||||
|
||||
Reference in New Issue
Block a user