#!/bin/bash
# Offline stub for arduino-fwuploader (ROSA package).
# The IDE probes "firmware list" at startup; the real binary downloads a
# firmware index from downloads.arduino.cc, which fails on offline machines.
# An empty list means "no updatable firmwares" — correct for offline use.
# The tiny sleep matters: the IDE reads stdout on the process 'exit' event,
# which for an instantly-exiting child can fire before the pipe flushes,
# causing an intermittent "Unexpected end of JSON input".
sleep 0.1
for a in "$@"; do
    [ "$a" = "list" ] && { echo '[]'; exit 0; }
done
exit 0
