#! /bin/sh dlg=gdialog bts=optiboot*.hex ls -1 $bts > /tmp/bootloaders.$$ i=1 while read line do echo $i "$line" >> /tmp/options.$$ i=$((i + 1)); done < /tmp/bootloaders.$$ options=$(cat /tmp/options.$$) length=$(ls -l $bts | wc -l) $dlg --stderr --title "Append Bootloader" --menu "Choose Bootloader:" 16 40 $length $options 2> /tmp/result.$$ if [ $? = 0 ]; then index=$(cat /tmp/result.$$) bt=$(ls -1 $bts | head -n $index | tail -n 1) head -n -1 $1 | sed 's/ //g' head -n -2 $bt | sed 's/ //g' tail -n 1 $bt | sed 's/ //g' fi $dlg --clear rm -f /tmp/bootloaders.$$ rm -f /tmp/options.$$ rm -f /tmp/result.$$