From: Roger Pueyo Centelles Date: Fri, 7 Dec 2018 17:04:10 +0000 (+0100) Subject: luci-app-bmx7: fix bmx7-info script's "$info" call X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=refs%2Fpull%2F431%2Fhead;p=feed%2Frouting.git 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 --- 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