grep CONFIG_INITRAMFS_SOURCE .config
if [ `grep -v "^#" .config | grep "CONFIG_NUVOTON_W55FA92_SM=m"` ]; then
echo "Configure with NAND"
cp -a drivers/scsi/nuvoton_nand/nanddrv.ko $ROOTFS/usr
else
echo "Configure without NAND"
if [ -f $ROOTFS/usr/nanddrv.ko ]; then
rm -f $ROOTFS/usr/nanddrv.ko
fi
fi
if [ `grep -v "^#" .config | grep "CONFIG_USB_FILE_STORAGE=m"` ]; then
echo "Configure with USBD mass storage"
cp -a drivers/usb/gadget/g_file_storage.ko $ROOTFS/usr
else
echo "Configure without USBD mass storage"
if [ -f $ROOTFS/usr/g_file_storage.ko ]; then
rm -f $ROOTFS/usr/g_file_storage.ko
fi
fi
其中 if 判斷表達式中 “” , ‘’ , ` ` 符合很容易搞錯。
linux中shell變量$#,$@,$0,$1,$2的含義解釋:
變量說明:
$$
Shell本身的PID(ProcessID)
$!
Shell最後運行的後臺Process的PID
$?
最後運行的命令的結束代碼(返回值)
$-
使用Set命令設定的Flag一覽
$*
所有參數列表。如"$*"用「"」括起來的情況、以"$1 $2 … $n"的形式輸出所有參數。
$@
所有參數列表。如"$@"用「"」括起來的情況、以"$1" "$2"… "$n" 的形式輸出所有參數。
$#
添加到Shell的參數個數
$0
Shell本身的文件名
$1~$n
添加到Shell的各參數值。$1是第1參數、$2是第2參數…。