From 3e259f8ec58f982ce565533f14006102ec9f6565 Mon Sep 17 00:00:00 2001 From: Roger Pueyo Centelles Date: Fri, 7 Dec 2018 18:04:10 +0100 Subject: [PATCH] luci-app-bmx7: fix bmx7-info script's "$info" call This commit fixes a bug in bmx7-info script's "$info" call when no interfaces are being used by BMX7, or when no links have been established. In those cases, the generated JSON output struct contained extra commas, which made it invalid. Closes #430 Signed-off-by: Roger Pueyo Centelles --- luci-app-bmx7/files/www/cgi-bin/bmx7-info | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/luci-app-bmx7/files/www/cgi-bin/bmx7-info b/luci-app-bmx7/files/www/cgi-bin/bmx7-info index c3f4418..7388ed1 100755 --- a/luci-app-bmx7/files/www/cgi-bin/bmx7-info +++ b/luci-app-bmx7/files/www/cgi-bin/bmx7-info @@ -82,7 +82,7 @@ print_query() { } # If the query is a file, just printing the file - [ -f "$BMX7_DIR/$1" ] && cat "$BMX7_DIR/$1"; + [ -f "$BMX7_DIR/$1" ] && [ -s "$BMX7_DIR/$1" ] && cat "$BMX7_DIR/$1" && return 0 || return 1 } if [ "${QUERY##*/}" == "all" ]; then @@ -94,10 +94,8 @@ if [ "$QUERY" == '$info' ]; then echo '{ "info": [ ' print_query status echo -n "," - print_query interfaces - echo -n "," - print_query links - echo -n "," + print_query interfaces && echo -n "," || echo -n '{ "interfaces": "" },' + print_query links && echo -n "," || echo -n '{ "links": "" },' print_mem echo "] }" fi -- 2.30.2