spaceship-prompt: Bad math expression

Issue

I get the following error

spaceship_battery:37: bad math expression: operator expected at `47'

Screenshot

Provide a screenshot that show your issue

screenshot

Environment

Operating system: Ubuntu 16.04 LTS Terminal emulator: Terminator ZSH version: zsh 5.1.1 (x86_64-ubuntu-linux-gnu)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 33 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Sure

λ upower -i /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SANYO
  model:                45N1773
  serial:               20253
  power supply:         yes
  updated:              Di 04 Dez 2018 12:51:48 CET (46 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              16,64 Wh
    energy-empty:        0 Wh
    energy-full:         16,97 Wh
    energy-full-design:  23,2 Wh
    energy-rate:         0 W
    voltage:             12,244 V
    percentage:          98%
    capacity:            73,1466%
    technology:          lithium-ion
    icon-name:          'battery-full-charged-symbolic'
  History (charge):
    1543924308	98,000	fully-charged

I’m getting this error too now (spaceship_battery:56: bad math expression: operator expected at '100') on macOS 10.14.1. That happened after I connected by device to a UPS.

  if [[ $SPACESHIP_BATTERY_SHOW == 'always' ||
        $battery_percent -lt $SPACESHIP_BATTERY_THRESHOLD || # <-- this is line 56
        $SPACESHIP_BATTERY_SHOW == 'charged' && $battery_status =~ "(charged|full)" ]]; then
$ pmset -g batt
Now drawing from 'AC Power'
 -InternalBattery-0 (id=3473507)	100%; charged; 0:00 remaining present: true
 -Back-UPS RS 900G FW:879.L4 .I USB FW:L4   (id=8126464)	100%; charging present: true

$ pmset -g batt | grep -oE '[0-9]{1,3}%'
100%
100%

Basically $battery_percent is 100\n100

I realize this is closed. But I wanted to comment for future me. Or others that google this. I am getting this and I am 99% certain it’s because I have two batteries. The number that is reported in the error message is the percentage from the second battery. If I new zsh more, I would submit a patch, but I don’t. I’m happy to help test if someone else wants to take a shot