Hi Nick,
if [ -e /media/sda1/e3-nand-backup.0 ]; then echo Found e3-nand-backup.0 echo " Erasing /dev/mtd0" flash_erase /dev/mtd0 0 16 echo " Writing e3-nand-backup.0 to /dev/mtd0" nandwrite -on /dev/mtd0 /media/sda1/e3-nand-backup.0 fi
Parameterise the code to extract the error-prone repetition, and avoid the reader having lots of versions to compare.
perhaps_write_flash() { p=${1?} erase=${2?} f=/media/sda1/e3-nand-backup.$p dev=/dev/mtd$p
test -e $f || return
echo found $f echo erasing $erase on $dev flash_erase $dev 0 $erase echo writing flash nandwrite -on $dev $f }
perhaps_write_flash 0 16 perhaps_write_flash 1 ...
Untested, obviously.