Closed obsy closed 4 years ago
@obsy this looks like a bad fix. We don't grep the entire file, we just grep the output of json_get_keys BOARDKEYS
, which does not contain ":" character or the literal quotation marks.
A better fix might be:
json_load_file "/etc/board.json"
json_get_keys BOARDKEYS
-SWITCHTEST=$(echo $BOARDKEYS | grep "switch")
+for KEY in $BOARDKEYS; do
+ [ "$KEY" = "switch" ] && SWITCHTEST="1"
+done
[ -n "$SWITCHTEST" ] || exit 0
json_select switch
Do you agree?
Looks good.
Thanks, i've pushed the fix
Some devices do not have "switch" section, but have "gpioswitch" section, ex Mikrotik 912:
This causes incorrect switch detection and errors like:
Fix this by explicitly searching for the "switch" section.