summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-04-20 23:05:01 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-04-20 23:19:37 -0400
commitcdc456c8b7c6e3eb4b11d668fb9c6e9bdec7230e (patch)
treed54d0c816a146023fbc7a54c0d5f71ecd0e69937 /src
parent23213bda24af601acbbea5731246a055680b48d0 (diff)
Don't use subshells in local/export/declare commands.
Only make this change in places where it shouldn't make a difference, and something weird has to be going on for the subshell to fail. This is on par with checking the return value of malloc. We don't need tests for each of these failure cases.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/abslibre-tools/librerelease5
-rwxr-xr-xsrc/aur2
-rw-r--r--src/chroot-tools/chcleanup.in3
-rw-r--r--src/chroot-tools/hooks-distcc.sh4
-rwxr-xr-xsrc/chroot-tools/librechroot5
-rwxr-xr-xsrc/chroot-tools/libremakepkg3
-rwxr-xr-xsrc/dagpkg6
-rwxr-xr-xsrc/librefetch/librefetch11
-rwxr-xr-xsrc/pkgbuild-check-nonfree7
-rwxr-xr-xsrc/xbs-abs/helper-abs15
-rwxr-xr-xsrc/xbs-abslibre/helper-abslibre12
11 files changed, 43 insertions, 30 deletions
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease
index 6d5651d..b8eb0e3 100755
--- a/src/abslibre-tools/librerelease
+++ b/src/abslibre-tools/librerelease
@@ -5,7 +5,7 @@
# Copyright (C) 2010-2012 Joshua Ismael Haase Hernández (xihh) <hahj87@gmail.com>
# Copyright (C) 2010-2013 Nicolás Reynolds <fauno@parabola.nu>
# Copyright (C) 2013 Michał Masłowski <mtjm@mtjm.eu>
-# Copyright (C) 2013-2014 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2013-2014, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# For just the create_signature() function:
# Copyright (C) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
@@ -191,7 +191,8 @@ clean() {
lock 8 "${WORKDIR}/staging.lock" \
'Waiting for an exclusive lock on the staging directory'
- local file_list="$(mktemp -t ${0##*/}.XXXXXXXXXX)"
+ local file_list
+ file_list="$(mktemp -t "${0##*/}.XXXXXXXXXX")"
trap "$(printf 'rm -f -- %q' "$file_list")" EXIT
list0_files > "$file_list"
diff --git a/src/aur b/src/aur
index 4dc7a99..03336eb 100755
--- a/src/aur
+++ b/src/aur
@@ -49,7 +49,7 @@ main() {
load_files libretools
check_vars libretools DIFFPROG || exit 1
- local startdir="$(pwd)"
+ local startdir=$PWD
local missing_deps=()
local ret=0
local pkg
diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in
index a7d2fb4..7981120 100644
--- a/src/chroot-tools/chcleanup.in
+++ b/src/chroot-tools/chcleanup.in
@@ -55,7 +55,8 @@ fi
source /etc/libretools.d/chroot.conf
# If we're running makepkg
if [[ -f PKGBUILD ]]; then
- export CARCH="$(. /etc/makepkg.conf; printf '%s' "$CARCH")"
+ CARCH="$(. /etc/makepkg.conf; printf '%s' "$CARCH")"
+ export CARCH
source ./PKGBUILD
CHROOTEXTRAPKG+=("${depends[@]}"
"${makedepends[@]}"
diff --git a/src/chroot-tools/hooks-distcc.sh b/src/chroot-tools/hooks-distcc.sh
index bb234b8..74edb85 100644
--- a/src/chroot-tools/hooks-distcc.sh
+++ b/src/chroot-tools/hooks-distcc.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
-# Copyright (C) 2013 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2013, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# License: GNU GPLv2+
#
@@ -62,7 +62,7 @@ distcc_start() {
_distcc_check
- local _distcc_tool="$(librelib chroot/distcc-tool)"
+ local _distcc_tool; _distcc_tool="$(librelib chroot/distcc-tool)"
install -m755 "$_distcc_tool" "$copydir/bin/distcc-tool"
mkdir -p "$home/.ssh"
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index dc242b2..fba7e91 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -180,8 +180,9 @@ calculate_directories() {
check_mountpoint() {
local file=$1
- local mountpoint="$(df -P "$file"|sed '1d;s/.*\s//')"
- local mountopts=($(LC_ALL=C mount|awk "{ if (\$3==\"$mountpoint\") { gsub(/[(,)]/, \" \", \$6); print \$6 } }"))
+ local mountpoint mountopts
+ mountpoint="$(df -P "$file"|sed '1d;s/.*\s//')"
+ mountopts=($(LC_ALL=C mount|awk "{ if (\$3==\"$mountpoint\") { gsub(/[(,)]/, \" \", \$6); print \$6 } }"))
! in_array nosuid "${mountopts[@]}" && ! in_array noexec "${mountopts[@]}"
}
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index d74c78b..5b86c03 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -268,7 +268,8 @@ main() {
# Set target CARCH
# note that we waited until after locking/creating the chroot to do this
- export CARCH="$(MAKEPKG_CONF=$copydir/etc/makepkg.conf get_var makepkg CARCH)"
+ CARCH="$(MAKEPKG_CONF=$copydir/etc/makepkg.conf get_var makepkg CARCH)"
+ export CARCH
# Pre-build
msg 'Starting pre-build activities...'
diff --git a/src/dagpkg b/src/dagpkg
index bcc2bc9..3856e0b 100755
--- a/src/dagpkg
+++ b/src/dagpkg
@@ -134,13 +134,13 @@ visit_pkgbuild() {
marks[$name]=1
# Recurse into dependencies
- local d
+ local d w
for d in "${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
# Cleanup dependency versions
- d=$(echo $d | sed "s/[<>=].*//")
+ d=${d%%<*}; d=${d%%>*}; d=${d%%=*}
# Where's the pkgbuild?
- local w=$(toru-where $d)
+ w=$(toru-where "$d")
# Skip if not available
test -z "$w" && continue
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch
index 2b8af61..855719d 100755
--- a/src/librefetch/librefetch
+++ b/src/librefetch/librefetch
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# librefetch
#
-# Copyright (C) 2013-2016 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2013-2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# For just the create_signature() function:
# Copyright (C) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
@@ -236,7 +236,8 @@ parse_options() {
local {shrt,long}{1,2}
# makepkg options
- local makepkg_orig="$(which makepkg)"
+ local makepkg_orig
+ makepkg_orig="$(which makepkg)"
shrt1=($(LC_ALL=C "${makepkg_orig}" -h | sed -rn 's/^ +-(.)(,| [^<]).*/\1/p'))
shrt2=($(LC_ALL=C "${makepkg_orig}" -h | sed -rn 's/^ +-(.) <.*/\1/p'))
long1=($(LC_ALL=C "${makepkg_orig}" -h | sed -rn -e 's/^ +(-., )?--(\S*) [^<].*/\2/p'))
@@ -310,7 +311,8 @@ parse_options() {
# Modify makepkg ###############################################################
modified_makepkg() {
- local dir="$(mktemp --tmpdir --directory "${cmd}.XXXXXXXXXXX.makepkg")"
+ local dir
+ dir="$(mktemp --tmpdir --directory "${cmd}.XXXXXXXXXXX.makepkg")"
make -s -f "$(librelib librefetchdir/Makefile)" new="$dir"
realpath -es "$dir/makepkg"
}
@@ -358,7 +360,8 @@ package() { cp -a "$srcdir"/*/ "$pkgdir/"; }
modified_pkgbuild() {
local pkgbuild=$1
- local srcbuild="$(mktemp "${pkgbuild%/*}/${cmd}.XXXXXXXXXXX.PKGBUILD.to.SRCBUILD")"
+ local srcbuild
+ srcbuild="$(mktemp "${pkgbuild%/*}/${cmd}.XXXXXXXXXXX.PKGBUILD.to.SRCBUILD")"
printf '%s' "$pkgbuild_append" | cat "$pkgbuild" - > "$srcbuild"
printf '%s\n' "$srcbuild"
}
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index e291dbe..59ec7c9 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -83,7 +83,7 @@ main() {
done
shift $((OPTIND - 1))
if [[ $# -lt 1 ]]; then
- pkgbuilds=("`pwd`/PKGBUILD")
+ pkgbuilds=("$PWD/PKGBUILD")
else
pkgbuilds=("$@")
fi
@@ -190,8 +190,9 @@ check_dep() {
[[ $# == 1 ]] || panic 'malformed call to check_dep'
local pkg=$1
- local line="$(blacklist-cat|blacklist-lookup "$pkg")"
- local rep="$(blacklist-get-rep <<<"$line")"
+ local line rep
+ line="$(blacklist-cat|blacklist-lookup "$pkg")"
+ rep="$(blacklist-get-rep <<<"$line")"
if [[ -z $line ]]; then
# not mentioned in blacklist; free
info '%s: not blacklisted' "$pkg"
diff --git a/src/xbs-abs/helper-abs b/src/xbs-abs/helper-abs
index 85a7fca..e8f41de 100755
--- a/src/xbs-abs/helper-abs
+++ b/src/xbs-abs/helper-abs
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2013-2014 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2013-2014, 2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# For code from db-functions (arch_svn):
# Copyright (C) 2012 Pierre Schmitz <pierre@archlinux.de>
@@ -98,7 +98,7 @@ release-client() {
local arch=$2
# Hack to use arch_svn as 'svn' in external scripts
- local tmpdir="$(mktemp -dt "xbs-abs-release.XXXXXXXXXX")"
+ local tmpdir; tmpdir="$(mktemp -dt "xbs-abs-release.XXXXXXXXXX")"
trap "$(printf 'rm -rf -- %q' "$tmpdir")" EXIT
printf '%s\n' \
'#!/bin/bash' \
@@ -126,7 +126,8 @@ unrelease() {
local tag="$repo-$arch"
load_config
- local svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
+ local svndir
+ svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
arch_svn up -q "$svndir"
# This is based off code from dbscripts:db-remove
@@ -140,7 +141,8 @@ move() {
local pkgbase=$3
load_config
- local svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
+ local svndir
+ svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
arch_svn up -q "$svndir"
local tag_list=""
@@ -181,9 +183,10 @@ releasepath() {
local arch=$3
load_config
- local svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
+ local svndir releasepath
+ svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
arch_svn up -q "${svndir}"
- local releasepath="${svndir}/repos/${repo}-${arch}"
+ releasepath="${svndir}/repos/${repo}-${arch}"
if [[ -f "${releasepath}/PKGBUILD" ]]; then
printf '%s\n' "$releasepath"
return 0
diff --git a/src/xbs-abslibre/helper-abslibre b/src/xbs-abslibre/helper-abslibre
index 10da489..eab37cd 100755
--- a/src/xbs-abslibre/helper-abslibre
+++ b/src/xbs-abslibre/helper-abslibre
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2012-2016 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2012-2017 Luke Shumaker <lukeshu@sbcglobal.net>
#
# License: GNU GPLv2+
#
@@ -83,8 +83,9 @@ release-client() {
local arch=$2
conf ABSLIBREDEST
- local pkgbase="$(load_PKGBUILD >/dev/null; printf '%s\n' "${pkgbase:-${pkgname}}")"
- local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
+ local pkgbase pkgdir
+ pkgbase="$(load_PKGBUILD >/dev/null; printf '%s\n' "${pkgbase:-${pkgname}}")"
+ pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
lockarch "$arch"
if [[ -e $pkgdir ]]; then
@@ -103,8 +104,9 @@ release-server() {
local arch=$2
conf ABSLIBREDEST
- local pkgbase="$(load_PKGBUILD >/dev/null; printf '%s\n' "${pkgbase:-${pkgname}}")"
- local pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
+ local pkgbase pkgdir
+ pkgbase="$(load_PKGBUILD >/dev/null; printf '%s\n' "${pkgbase:-${pkgname}}")"
+ pkgdir="${ABSLIBREDEST}/${arch}/${repo}/${pkgbase}"
lockarch "$arch"
checkgit