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

Eli Schwartz eschwartz at archlinux.org
Mon Feb 19 22:17:23 UTC 2018

On 02/19/2018 04:53 PM, Luke Shumaker wrote:
> Isn't [[ -d ]] there redundant?  If globbing gave us $dir/file, of
> course $dir is a directory!

True. I think I still had that in from some point where I hadn't enabled
nullglob yet.

> 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.

It is not important, the find command only checked if the file itself
was a symlink but if there is another package file in the same directory
then we still add those staging repos.

Meanwhile, we check later on for `die "Package %s is a symbolic link"`.
So I guess technically it would make more sense to stage the package and
then utilize the explicit error message rather than silently dropping
the package altogether (but only sometimes) simply because we didn't
think to use -xtype.

At this stage in the game, we're just trying to assemble a list of the
packages that the uploader is asserting they want to db-update. We
perform all actual validation later on.

Eli Schwartz
Bug Wrangler and Trusted User

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/arch-projects/attachments/20180219/a36830ea/attachment.asc>

More information about the arch-projects mailing list