Ok, thanks for the suggestions. I've settled on this method:
First check that the user is in the disk group (necessary for the authority to write to usb devices, on Debian/Ubuntu distros, at least).
Check the file has suffix .img, or .iso, or is a .gz containing a single file (like raspbmc) or a .zip containing a single file (like raspian).
Scan /dev/sdb, dev/sdc, etc until the first USB-connected device is found.
Get the "ID_Model" string of the SD adaptor, which is things like: "SD_MMCReader" "CARD-READER" "Flash_Reader" "Storage_Device" "Multi-Card" or for flash sticks, "Flash_Disk" or "USB_Mass_Storage_Device".
Prompt the user with the above info and ask if it's OK to continue.
pv needs to be installed to provide a nice progress bar and ETA etc, but the other commands (udevadm, unzip, funzip) are default on Ubuntu/Debian.
I've tested it and it seems to be fully functional:
#!/bin/bash # burn specified iso to usb flash (verifies that it IS on USB) fail() { echo Error: $*; exit 1; } [[ -z $(grep '\bdisk\b' < &1 | grep ID_BUS=usb) ]] && break done sd=$(udevadm info /dev/sd$n | grep 'ID_MODEL=' | sed 's/.*ID_MODEL=//') read -p "Burn $1 into \"$sd\" at /dev/sd$n [Yn]" yn [[ "$yn" == [nN]* ]] && exit 1 [[ "$1" == ?(*.zip|*.gz) ]] && fz=funzip || fz='tee' pv -tpreb "$1" | $fz | dd bs=1M oflag=dsync of="/dev/sd$n"