From b69fad50682798b7e1907742738dca2c02d00fd2 Mon Sep 17 00:00:00 2001 From: Shy Date: Wed, 7 Aug 2024 23:10:02 +0200 Subject: [PATCH 1/3] Print status message only if stdout is a terminal. --- wled | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled b/wled index d61f3e1..b46f8b9 100755 --- a/wled +++ b/wled @@ -131,7 +131,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. From b764a46ded2037749ce340872e2d8aa30bd6fb81 Mon Sep 17 00:00:00 2001 From: Shy Date: Thu, 8 Aug 2024 19:37:55 +0200 Subject: [PATCH 2/3] Print usage when called without flags. --- wled | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wled b/wled index b46f8b9..c0e89ff 100755 --- a/wled +++ b/wled @@ -70,10 +70,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 ;; From 654b7ff48046d3ebb62f68039f82180446db2585 Mon Sep 17 00:00:00 2001 From: Shy Date: Thu, 8 Aug 2024 19:53:24 +0200 Subject: [PATCH 3/3] Make zsh-compatible. --- wled | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wled b/wled index c0e89ff..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