#include #include #include int no_error(const char *p, int e) { return 0; } int test_glob(const char *p) { glob_t g; int result = false; result = glob(p, GLOB_TILDE, no_error, &g); printf("result:%d", result); if(result == 0) { for(int i = 0; i < g.gl_pathc; ++i) { printf(" '%s'", g.gl_pathv[i]); } } printf("\n"); } int main(int argc, char **argv) { (void) argc; (void) argv; test_glob("~"); test_glob("~/p*"); test_glob("~bpf"); test_glob("~bpf/p*"); return 0; }