geometry-zsh / geometry

geometry is a minimal, fully customizable and composable zsh prompt theme
ISC License
921 stars 94 forks source link

geometry_status: bad math expression - operand expected at `"..."` #275

Closed alxbl closed 4 years ago

alxbl commented 4 years ago

I'm not sure if this is a regression related to the recent autoloading, but I started getting this after pulling the lazy loading feature. The code in geometry_status does not appear to have changed recently, which makes this even more puzzling. This seems to happen when GEOMETRY_STATUS_SYMBOL_COLOR_HASH=true and attempting to color the prompt:

alex@host ~ $ whoami
alex
geometry_status:16: bad math expression: operand expected at `"88"'
geometry_status:16: bad math expression: operand expected at `"82"'
geometry_status:16: bad math expression: operand expected at `"88"'
geometry_status:16: bad math expression: operand expected at `"52"'
geometry_status:16: bad math expression: operand expected at `"57"'
geometry_status:16: bad math expression: operand expected at `"65"'
geometry_status:16: bad math expression: operand expected at `"56"'
geometry_status:16: bad math expression: operand expected at `"51"'
geometry_status:16: bad math expression: operand expected at `"70"'

In any case, I've resolved the issue by doing the following:

diff --git a/functions/geometry_status b/functions/geometry_status
index 48d7cf1..30f2fa0 100644
--- a/functions/geometry_status
+++ b/functions/geometry_status
@@ -16,7 +16,7 @@ geometry_status() {
         colors=(${GEOMETRY_STATUS_SYMBOL_COLOR_HASH_COLORS})
       fi

-      local sum=0; for c in ${(s::)^HOST}; do ((sum += "$(print -f '%d' "'$c")")); done
+      local sum=0; for c in ${(s::)^HOST}; do ((sum += $(print -f '%d' "'$c") )); done

       local index="$(($sum % ${#colors}))"

I can make a PR to fix the issue or you can apply the patch yourself, I just want to make sure that this is not an issue on my end before making code changes.

Cheers, Alex

jedahan commented 4 years ago

Definitely a regression, thanks for the investigation and fix. Feel free to PR (I invited you as a collaborator since you've been doing so much good work for geometry).

jedahan commented 4 years ago

Also confirmed that patch fixed it.

alxbl commented 4 years ago

Thanks for the invite. I'll still go through PRs just for the sake of peer review. I'll make the PR tomorrow morning.

Looking forward to v2 official release :)