diff --git a/wled b/wled index d61f3e1..8ed3fab 100755 --- a/wled +++ b/wled @@ -13,6 +13,11 @@ VERSION="0.1.3" exit_code=0 host_list= +# Shell specific options. +case "$(readlink /proc/$$/exe)" in + */zsh) setopt SH_WORD_SPLIT ;; +esac + # Make the exit status of command pipelines the status of the last command # with non-zero exit status - if supported by this shell. (set -o pipefail 2>/dev/null) && set -o pipefail @@ -70,10 +75,15 @@ current_brightness() { sed -n 's/.*"state"[[:space:]]*:[[:space:]]*{[^}]*"bri"[[:space:]]*:[[:space:]]*\([0-9]\{1,3\}\).*/\1/p' } +if test $# -eq 0; then + print_help + exit 0 +fi + # Parse instance argument and store hostnames. while test $# -gt 0; do case "$1" in - ""|-h|--help) # Missing instance parameter. + -h|--help) print_help exit 0 ;; @@ -131,7 +141,7 @@ for wled_host in $host_list; do api_resp=$(curl_send "{'ps':$1}" "http://$wled_host/json") ;; l|list) # List presets. - printf "loading ...\r" + test -t 1 && printf 'connecting ...\r' active_ps=$(active_preset "$wled_host") curl_fetch "http://$wled_host/presets.json" | \ # Insert newline in front of every preset slice.