Something like this:
(I made just minimal change and even left the if clause)
root@router4:~# cat /etc/toggle_bootcmd
#!/bin/sh
#
# This script can change the bootcmd in the u-boot bootloader
# of E8450 / RT3200 UBI variant to boot either into
# * initramfs recovery if pstore crash logs are detected (default)
# * main OpenWrt despite the crash log files in pstore
cur_bootcmd=$(fw_printenv -n bootcmd)
echo "Current setting: bootcmd=$cur_bootcmd"
echo -e "\nOptions:\n" \
"-i Boot into initramfs if crash files are present\n" \
"-o Boot always into normal OpenWrt\n"
if [ "$1" = "-i" ]
then
echo "Set bootcmd to use initramfs if pstore files present"
fw_setenv bootcmd "if pstore check ; then run boot_recovery ; else run boot_ubi ; fi"
elif [ "$1" = "-o" ]
then
echo "Set bootcmd to always boot into normal OpenWrt"
fw_setenv bootcmd "if pstore check ; then run boot_ubi ; else run boot_ubi ; fi"
else
echo -e "\nNo operation selected"
fi
sync
fw_printenv bootcmd