I'm running a command with output based on some files. So I cat
the files inside the command. However, when there's nothing in the file, this is problematic
mkbootimg --kernel "$SCRIPT_DIR/devices/$DEVICE/kernel/k/arch/arm64/boot/Image" \
--ramdisk boot.img-ramdisk \
--dtb boot.img-dtb \
--cmdline "$(cat boot.img-cmdline)" \
--base `cat boot.img-base` \
--kernel_offset `cat boot.img-kernel_offset` \
--ramdisk_offset `cat boot.img-ramdisk_offset` \
--tags_offset `cat boot.img-tags_offset` \
--dtb_offset `cat boot.img-dtb_offset` \
--os_version `cat boot.img-os_version` \
--os_patch_level `cat boot.img-os_patch_level` \
--pagesize `cat boot.img-pagesize` \
--header_version `cat boot.img-header_version` \
--hashtype `cat boot.img-hashtype` \
--board `cat boot.img-board` \
--ramdisk_offset `cat boot.img-ramdisk_offset` \
-o ../boot.img)
For example, if there's nothing on boot.img-board
then it does
--board --ramdisk_offset 0x10000
and thus it thinks that the board
is --ramdisk_offset
and then interprets 0x10000
as another argument for mkbootimg
.
What is the best way to solve this problem? Howe can I only do --board
when there's actually something inside boot.img-board
?
I want to do this for all arguments, so maybe a function that returns the argument would make more sense here.
What if the program really expects something in --OPTION so you should only pass if there's something there?