setting USE="+int32 int64" and running if has int32 ${IUSE}; then... results in ++ has int32 static-libs test abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64 +int32 int64 ++ local needle=int32 ++ shift ++ local x ++ for x in '"$@"' ++ '[' static-libs = int32 ']' ++ for x in '"$@"' ++ '[' test = int32 ']' ++ for x in '"$@"' ++ '[' abi_x86_32 = int32 ']' ++ for x in '"$@"' ++ '[' abi_x86_64 = int32 ']' ++ for x in '"$@"' ++ '[' abi_x86_x32 = int32 ']' ++ for x in '"$@"' ++ '[' abi_mips_n32 = int32 ']' ++ for x in '"$@"' ++ '[' abi_mips_n64 = int32 ']' ++ for x in '"$@"' ++ '[' abi_mips_o32 = int32 ']' ++ for x in '"$@"' ++ '[' abi_ppc_32 = int32 ']' ++ for x in '"$@"' ++ '[' abi_ppc_64 = int32 ']' ++ for x in '"$@"' ++ '[' abi_s390_32 = int32 ']' ++ for x in '"$@"' ++ '[' abi_s390_64 = int32 ']' ++ for x in '"$@"' ++ '[' +int32 = int32 ']' ++ for x in '"$@"' ++ '[' int64 = int32 ']' ++ return 1
The has() function behaves as specified by PMS. The in_iuse function from eutils.eclass does what you want.
*** This bug has been marked as a duplicate of bug 449862 ***
Note that has() works with ${IUSE_EFFECTIVE}, and it includes flags specified by the profile via the IUSE_IMPLICIT and USE_EXPAND_IMPLICIT variables.
(In reply to Zac Medico from comment #3) > Note that has() works with ${IUSE_EFFECTIVE}, and it includes flags > specified by the profile via the IUSE_IMPLICIT and USE_EXPAND_IMPLICIT > variables. But certainly we don't want to encourage usage of IUSE_EFFECTIVE in ebuilds? By section 11.1.1, IUSE_REFERENCEABLE and IUSE_EFFECTIVE are conceptual variables which are not exported to the ebuild environment. https://projects.gentoo.org/pms/5/pms.html#x1-11900011.1.1
Then in_iuse from eutils probably the best approach, until EAPI 6 is released.
(In reply to Zac Medico from comment #5) > Then in_iuse from eutils probably the best approach, until EAPI 6 is > released. That's what I found. To find something suitable I used qgrep but in_iuse is only used in eclasses not in ebuilds so it didn't pop up and I tried has()