[arch-projects] [dbscripts] [PATCH 1/3] db-update: replace external find command with bash globbing

Eli Schwartz eschwartz at archlinux.org
Fri Feb 16 03:45:02 UTC 2018


Don't bother emitting errors. bash doesn't show globbing errors if it
cannot read a directory to try globbing there. And the former code never
aborted on errors anyway, as without `set -o pipefail` the sort command
swallowed the return code.

Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
 db-functions | 4 ++++
 db-update    | 9 ++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/db-functions b/db-functions
index e8949d7..f0f8980 100644
--- a/db-functions
+++ b/db-functions
@@ -2,6 +2,10 @@
 
 . /usr/share/makepkg/util.sh
 
+# global shell options for enhanced bash scripting
+shopt -s globstar nullglob
+
+
 # Some PKGBUILDs need CARCH to be set
 CARCH="x86_64"
 
diff --git a/db-update b/db-update
index 45755a4..fa024b3 100755
--- a/db-update
+++ b/db-update
@@ -9,9 +9,12 @@ if (( $# >= 1 )); then
 fi
 
 # Find repos with packages to release
-if ! staging_repos=($(find  "${STAGING}" -mindepth 1 -type f -name "*${PKGEXT}" -printf '%h\n' | sort -u)); then
-	die "Could not read %s" "$STAGING"
-fi
+for f in "${STAGING}"/**/*${PKGEXT}; do
+	f="${f%/*}"
+	if [[ -d $f ]] && ! in_array "$f" "${staging_repos[@]}"; then
+		staging_repos+=("$f")
+	fi
+done
 
 repos=()
 for staging_repo in ${staging_repos[@]##*/}; do
-- 
2.16.1


More information about the arch-projects mailing list