diff options
author | Leah Rowe <leah@libreboot.org> | 2023-09-30 18:41:57 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-09-30 19:09:25 +0100 |
commit | 0a0defd3256ff5e29e3b4d129a04fb7546bc31ac (patch) | |
tree | 479d686f0578b506dbe3f862300e73c090ed8bcc /include | |
parent | 49b266eb4248f87d111e9babae86a873300afa03 (diff) |
simplify initialising variables in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rwxr-xr-x | include/blobutil.sh | 26 | ||||
-rwxr-xr-x | include/err.sh | 12 |
2 files changed, 19 insertions, 19 deletions
diff --git a/include/blobutil.sh b/include/blobutil.sh index 873d368d..51f11de9 100755 --- a/include/blobutil.sh +++ b/include/blobutil.sh @@ -4,7 +4,6 @@ _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" _7ztest="a" -_b="" blobdir="blobs" appdir="${blobdir}/app" cbdir="coreboot/default" @@ -12,7 +11,6 @@ cbcfgsdir="config/coreboot" ifdtool="cbutils/default/ifdtool" cbfstool="cbutils/default/cbfstool" nvmutil="util/nvmutil/nvm" -boarddir="" pciromsdir="pciroms" mecleaner="$(pwd)/me_cleaner/me_cleaner.py" @@ -22,28 +20,18 @@ kbc1126_ec_dump="$(pwd)/${cbdir}/util/kbc1126/kbc1126_ec_dump" pfs_extract="$(pwd)/biosutilities/Dell_PFS_Extract.py" uefiextract="$(pwd)/uefitool/uefiextract" -setvars="EC_url=\"\"" -for x in EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup E6400_VGA_DL_hash \ - E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset E6400_VGA_romname \ - SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash MRC_url \ - MRC_url_bkup MRC_hash MRC_board _dest; do - setvars="${setvars}; ${x}=\"\"" -done +eval "$(setvars "" EC_url EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup _dest \ + E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ + E6400_VGA_romname SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \ + MRC_url MRC_url_bkup MRC_hash MRC_board archive rom board modifygbe _dl \ + new_mac release releasearchive _b boarddir)" -for x in archive rom board modifygbe new_mac release releasearchive _dl; do - setvars="${setvars}; ${x}=\"\"" -done - -for x in CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \ +eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \ CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \ CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET \ CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_GBE_BIN_PATH \ CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE \ - CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE; do - setvars="${setvars}; ${x}=\"\"" -done - -eval "${setvars}" + CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE)" check_defconfig() { diff --git a/include/err.sh b/include/err.sh index 96252534..9f7c63b0 100755 --- a/include/err.sh +++ b/include/err.sh @@ -1,6 +1,18 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org> +setvars() +{ + _setvars="" + [ $# -lt 2 ] && err "setvars: too few arguments" + val="${1}" + shift 1 + for var in $@; do + _setvars="${var}=\"${val}\"; ${_setvars}" + done + printf "%s\n" "${_setvars% }" +} + err() { printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2 |