Skip to content

Commit

Permalink
Merge pull request #233 from lodewijkvankeizerswaard/checkchargeargs
Browse files Browse the repository at this point in the history
Fix for #104: added integer check for charge command argument
  • Loading branch information
actuallymentor authored Mar 23, 2024
2 parents 902c0b8 + 2fe4a39 commit 481610a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ fi
# Charging on/off controller
if [[ "$action" == "charge" ]]; then

# Check if percentage is an integer [1-100]
if ! [[ $setting =~ ^[1-9][0-9]?$|^100$ ]]; then
log "Specified percentage ($setting) is not valid. Please specify an integer [1-100]."
exit 1
fi

# Disable running daemon
battery maintain stop

Expand Down

0 comments on commit 481610a

Please sign in to comment.