/* * ./bash_cv_opendir_not_robust && echo 'yes' || echo 'no' */ #include #include #include #define HAVE_UNISTD_H 1 #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #define HAVE_DIRENT_H 1 #if defined(HAVE_DIRENT_H) # include #else # define dirent direct # ifdef HAVE_SYS_NDIR_H # include # endif /* SYSNDIR */ # ifdef HAVE_SYS_DIR_H # include # endif /* SYSDIR */ # ifdef HAVE_NDIR_H # include # endif #endif /* HAVE_DIRENT_H */ main() { DIR *dir; int fd, err; err = mkdir("/tmp/bash-aclocal", 0700); if (err < 0) { perror("mkdir"); exit(1); } unlink("/tmp/bash-aclocal/not_a_directory"); fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666); write(fd, "\n", 1); close(fd); dir = opendir("/tmp/bash-aclocal/not_a_directory"); unlink("/tmp/bash-aclocal/not_a_directory"); rmdir("/tmp/bash-aclocal"); exit (dir == 0); }