mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-14 07:19:40 +02:00
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>
This commit is contained in:
+13
-12
@@ -13,13 +13,13 @@ projectsite="https://libreboot.org/"
|
||||
[ -z "${PATH+x}" ] && \
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
|
||||
|
||||
eval "`setvars "" _nogit board reinstall versiondate aur_notice configdir \
|
||||
eval "$(setvars "" _nogit board reinstall versiondate aur_notice configdir \
|
||||
datadir version xbmkpwd relname xbmkpwd xbtmp python pyver xbmklock \
|
||||
cvxbmk cvchk xbmkpath is_child basetmp`"
|
||||
cvxbmk cvchk xbmkpath is_child basetmp)"
|
||||
|
||||
xbmk_init()
|
||||
{
|
||||
xbmkpwd="`pwd`" || err "Cannot generate PWD"
|
||||
xbmkpwd="$(pwd || err "Cannot generate PWD")" || err
|
||||
xbmklock="$xbmkpwd/lock"
|
||||
basetmp="$xbmkpwd/xbmkwd"
|
||||
|
||||
@@ -41,7 +41,7 @@ xbmkpkg()
|
||||
[ $# -lt 2 ] && err "fewer than two arguments"
|
||||
[ $# -gt 2 ] && reinstall="$3"
|
||||
|
||||
eval "`setcfg "config/dependencies/$2"`"
|
||||
eval "$(setcfg "config/dependencies/$2")"
|
||||
|
||||
chkvars pkg_add pkglist
|
||||
x_ $pkg_add $pkglist
|
||||
@@ -94,12 +94,12 @@ xbmk_set_env()
|
||||
|
||||
xbmk_child_set_tmp()
|
||||
{
|
||||
eval `setvars "" xbtmp badtmp xbtmpchk xbtmpname`
|
||||
eval "$(setvars "" xbtmp badtmp xbtmpchk xbtmpname)"
|
||||
|
||||
[ -z "${TMPDIR+x}" ] && export TMPDIR="$basetmp"
|
||||
|
||||
# extremely pedantic safety checks on TMPDIR
|
||||
xbtmpchk="`findpath "$TMPDIR" || err`" || err
|
||||
xbtmpchk="$(findpath "$TMPDIR" || err "!findpath $TMPDIR")" || err
|
||||
[ "$xbtmpchk" = "${xbtmpchk#"$basetmp/"}" ] && \
|
||||
badtmp="not a subdirectory in $basetmp"
|
||||
[ -z "$badtmp" ] && xbtmpname="${xbtmpchk#"$basetmp/"}" && \
|
||||
@@ -130,7 +130,7 @@ xbmk_parent_check_tmp()
|
||||
{
|
||||
export TMPDIR="$basetmp"
|
||||
|
||||
xbmklist="`mktemp || err "can't make tmplist"`" || err
|
||||
xbmklist="$(mktemp || err "can't make tmplist")" || err
|
||||
x_ rm -f "$xbmklist"
|
||||
x_ touch "$xbmklist"
|
||||
for xtmpdir in "$basetmp"/xbmk_*; do
|
||||
@@ -140,7 +140,7 @@ xbmk_parent_check_tmp()
|
||||
done
|
||||
|
||||
# set up a unified temporary directory, for common deletion later:
|
||||
export TMPDIR="`mktemp -d -t xbmk_XXXXXXXX || err`" || err
|
||||
export TMPDIR="$(x_ mktemp -d -t xbmk_XXXXXXXX)" || err
|
||||
xbtmp="$TMPDIR"
|
||||
|
||||
while read -r xtmpdir; do
|
||||
@@ -198,7 +198,7 @@ xbmk_set_pyver()
|
||||
pybin python3 1>/dev/null || python="python"
|
||||
pyver="2" && [ "$python" = "python3" ] && pyver="3"
|
||||
pybin "$python" 1>/dev/null || pyver=""
|
||||
[ -z "$pyver" ] || "`pybin "$python"`" -c "$pyv" 1>/dev/null \
|
||||
[ -z "$pyver" ] || "$(x_ pybin "$python")" -c "$pyv" 1>/dev/null \
|
||||
2>/dev/null || err "Cannot detect host Python version."
|
||||
[ -n "$pyver" ] && \
|
||||
pyver="$("$(pybin "$python")" -c "$pyv" | awk '{print $1}')" && \
|
||||
@@ -209,7 +209,7 @@ xbmk_set_pyver()
|
||||
# set up python v3.x in PATH, in case it's not set up correctly.
|
||||
# see code above that detected the correct python3 command.
|
||||
x_ cd "$xbtmp/xbmkpath"
|
||||
x_ ln -s "`pybin "$python"`" python
|
||||
x_ ln -s "$(x_ pybin "$python")" python || err
|
||||
) || err "Can't set up python symlink in $xbtmp/xbmkpath"; :
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ pybin()
|
||||
|
||||
# ideally, don't rely on PATH or hardcoded paths if python venv.
|
||||
# use the *real*, direct executable linked to by the venv symlink
|
||||
if [ $venv -gt 0 ] && [ -L "`command -v "$1" 2>/dev/null`" ]; then
|
||||
if [ $venv -gt 0 ] && [ -L "$(command -v "$1" 2>/dev/null)" ]; then
|
||||
pypath="$(findpath \
|
||||
"$(command -v "$1" 2>/dev/null)" 2>/dev/null || :)"
|
||||
[ -e "$pypath" ] && [ ! -d "$pypath" ] && \
|
||||
@@ -257,7 +257,8 @@ xbmk_git_init()
|
||||
x_ date --version | grep "GNU coreutils" 1>/dev/null 2>/dev/null || \
|
||||
err "Non-GNU date implementation; current use relies on GNU date"
|
||||
|
||||
eval "`setvars "$(date -Rud @$versiondate)" cdate _nogit`"
|
||||
eval "$(setvars "$(x_ date -Rud @$versiondate)" cdate _nogit || err)" \
|
||||
err
|
||||
|
||||
x_ git init 1>/dev/null 2>/dev/null
|
||||
x_ git add -A . 1>/dev/null 2>/dev/null
|
||||
|
||||
Reference in New Issue
Block a user