diff options
author | Leah Rowe <leah@libreboot.org> | 2025-09-11 10:17:50 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-09-11 10:29:59 +0100 |
commit | 4999a49de39667b3239fc2010d0e99c958b29417 (patch) | |
tree | dfa4897896de0bc0c93c5133052a566b5339c138 /include/lib.sh | |
parent | 5cfe54b06d74e6392fc7312c41b5ca299704f7ca (diff) |
xbmk: don't use backticks for command substitution
the newer way handles escaped characters better, and it
can be nested more easily. it's also more readable.
personally, i prefer the old way, because it's more
minimalist, but it occurs to me that a lot of people
nowadays don't know about backticks, but they do know
of the modern way.
to make the code more readable, i have modernised it.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/lib.sh')
-rw-r--r-- | include/lib.sh | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/lib.sh b/include/lib.sh index a2b93a97..1f8687fb 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -32,11 +32,11 @@ xbmk_sanitize_version() { [ -n "$version" ] || return 0; : - version="`printf "%s\n" "$version" | sed -e 's/\t//g'`" - version="`printf "%s\n" "$version" | sed -e 's/\ //g'`" - version="`printf "%s\n" "$version" | sed -e 's/\.\.//g'`" - version="`printf "%s\n" "$version" | sed -e 's/\.\///g'`" - version="`printf "%s\n" "$version" | sed -e 's/\//-/g'`" + version="$(printf "%s\n" "$version" | sed -e 's/\t//g')" + version="$(printf "%s\n" "$version" | sed -e 's/\ //g')" + version="$(printf "%s\n" "$version" | sed -e 's/\.\.//g')" + version="$(printf "%s\n" "$version" | sed -e 's/\.\///g')" + version="$(printf "%s\n" "$version" | sed -e 's/\//-/g')" version="${version#-}" [ -n "$version" ] || err "'version' empty after sanitization"; : @@ -103,8 +103,8 @@ findpath() { [ $# -gt 0 ] || err "findpath: No arguments provided" while [ $# -gt 0 ]; do - found="`readlink -f "$1" 2>/dev/null`" || return 1; : - [ -n "$found" ] || found="`realpath "$1" 2>/dev/null`" || \ + found="$(readlink -f "$1" 2>/dev/null)" || return 1; : + [ -n "$found" ] || found="$(realpath "$1" 2>/dev/null)" || \ return 1; : printf "%s\n" "$found" shift 1 @@ -113,7 +113,7 @@ findpath() pad_one_byte() { - paddedfile="`mktemp`" || err "mktemp pad_one_byte" + paddedfile="$(mktemp || err "mktemp pad_one_byte")" || err x_ cat "$1" config/data/coreboot/0 > "$paddedfile" || err "!pad $1"; : x_ mv "$paddedfile" "$1" } @@ -123,14 +123,14 @@ unpad_one_byte() xromsize="$(expr $(stat -c '%s' "$1") - 1)" || err "!int" [ $xromsize -lt 524288 ] && err "too small, $xromsize: $1" - unpaddedfile="`mktemp`" || err "mktemp unpad_one_byte" + unpaddedfile="$(mktemp || err "mktemp unpad_one_byte")" || err x_ dd if="$1" of="$unpaddedfile" bs=$xromsize count=1 x_ mv "$unpaddedfile" "$1" } fx_() { - fd="`mktemp || err "can't create tmpfile"`" || err + fd="$(mktemp || err "can't create tmpfile")" || err x_ rm -f "$fd" && x_ touch "$fd" xx="$1" && shift 1 "$@" 2>/dev/null | sort 1>"$fd" 2>/dev/null || err "FATAL: !sort fx_" |