Unverified Commit 6ef456d7 authored by Mark Vander Stel's avatar Mark Vander Stel
Browse files

Fix zsh glob error

Zsh by default will error if a glob matches nothing (a smart default).
We need it to not error, and even better, to not use the Bash default of
using the pattern. Set nullglob to expand it to nothing.

Don't set the Bash version of nullglob in liquidprompt, since Bash
doesn't do local options well, and not at all until version 4.4. It is
safe to expand to a single string with the "*" in it, since the first
check we do is for the file existing, which it will not.

Add the sysfs power supply interface to the external-tool-tester.sh.
parent 2c04232c
......@@ -2342,6 +2342,10 @@ _lp_wifi() {
case "$LP_OS" in
Linux)
__lp_battery_sysfs() {
if (( _LP_SHELL_zsh )); then
setopt local_options nullglob
fi
local power_supply
for power_supply in "${_LP_LINUX_POWERSUPPLY_PATH}/"*; do
if ! [[ -r "${power_supply}/type" && -r "${power_supply}/present" && \
......
......@@ -3,6 +3,13 @@
# Do NOT error on failed commands
set +e
# Don't error (or do anything) for no matching globs.
if [ -n "${ZSH_VERSION-}" ]; then
setopt nullglob
else # Bash
shopt -s nullglob
fi
# Error if the output is a terminal
if [ -t 1 ]; then
printf 'This script must be redirected to a file, or special characters will be lost
......@@ -64,6 +71,11 @@ test_tool logname
test_tool screen -ls
test_tool tmux list-sessions
for power_supply in "/sys/class/power_supply/"*; do
for interface in "${power_supply}/"*; do
test_tool cat "$interface"
done
done
test_tool acpi --battery
test_tool pmset -g batt
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment