Hi,
Matt recently made a PR to a QA check script in Portage [1] which
included the following function:
is_in() {
local needle=$1
shift
local x
for x in "$@"; do
[[ "${needle}" = ${x} ]] && return 0
done
return 1
}
It's more or less `has` but with Bash pattern matching support. The
difference is in how it handles the conditional. For reference, here is
the implementation of `has` in Portage:
has() {
local needle=$1
shift
local x
for x in "$@"; do
[[ "${x}" = "${needle}" ]] && return 0
done
return 1
}
We agreed that it could potentially be useful as something that's
available for general use, so I'd like to propose the idea of adding the ability to query a list for something like "foo*" or "foob??". Here's
two possibilities for how I would go about implementing it:
1. Add Matt's function. Perhaps as `hasp` (for "has pattern") or
something.
2. Change `has` to support pattern matching in EAPI 9+
Thoughts?
- Oskari
[1]:
https://github.com/gentoo/portage/pull/1034
-----BEGIN PGP SIGNATURE-----
iHUEABYIAB0WIQQfOU+JeXjo4uxN6vCp8he9GGIfEQUCZGRgNwAKCRCp8he9GGIf EW91APwJx/c1XJgWkS/w4IjV7u8/eEwGTLhVZxmkiNm+/MBcNwD/SD5HlN7J3Xky xc+y05uOq7/drR2IhavJE6kHDwYP/Q0=
=XWQT
-----END PGP SIGNATURE-----
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)