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 <roger.pueyo@guifi.net>
}
# 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
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