This fixes a bug introduced in #27831: `for path in "$dir"/lib*.so` assumed that all libs match `lib*.so`, but 07674788 started adding libs that match `*.so` and `*.so.*`.