On Mon, 19 Feb 2018 15:11:43 -0500,
Eli Schwartz via arch-projects wrote:
> --- a/db-update
> +++ b/db-update
> @@ -9,9 +9,14 @@ if (( $# >= 1 )); then
> fi
>
> # Find repos with packages to release
> -if ! staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name
> "*${PKGEXTS}" -printf '%h\n' | sort -u)); then
> - die "Could not read %s" "$STAGING"
> -fi
> +mapfile -t -d '' staging_repos < <(
> + for f in "${STAGING}"/**/*${PKGEXTS}; do
> + f="${f%/*}"
> + if [[ -d $f ]]; then
> + printf '%s\0' "$f"
> + fi
> + done | sort -uz
> +)
>
> repos=()
> for staging_repo in ${staging_repos[@]##*/}; do
Isn't [[ -d ]] there redundant? If globbing gave us $dir/file, of
course $dir is a directory!
Meanwhile, this dropped the `-type f` check, though I'm not sure how
important that was.
Shouldn't this be written as:
mapfile -t -d '' staging_repos < <(
for f in "${STAGING}"/**/*${PKGEXTS}; do
if [[ -f $f && ! -h $f ]]; then
printf '%s\0' "${f/*}"
fi
done | sort -uz
)
The original `find` command rejected symlinks; I don't know if that's
an important property; but that's what the `&& ! -h $f` bit is for.
--
Happy hacking,
~ Luke Shumaker