From fb6d4e6cb42ffacfbe300021f062b5057ba7015d Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 1 Oct 2013 05:34:36 +0000 Subject: [PATCH] Support libc's without GLOB_TILDE GLOB_TILDE is a GNU extension and may not be present on all systems. Note (jcapik): The original patch from Michael Forney didn't apply cleanly due to my recent addition of the GLOB_BRACE flag in the list of flags. I had to edit the patch to make it apply, but that produces an inconsistent state. It's gonna be fixed in the next commit. --- sysctl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sysctl.c b/sysctl.c index bc83b50f..08d5641f 100644 --- a/sysctl.c +++ b/sysctl.c @@ -502,7 +502,15 @@ static int Preload(const char *restrict const filename) int globerr; int j; +#ifdef GLOB_TILDE globerr = glob(filename, GLOB_NOCHECK | GLOB_TILDE | GLOB_BRACE, NULL, &globbuf); +#else + if (filename[0] == '~') + xwarnx(_("GLOB_TILDE is not supported on your platform, " + "the tilde in \"%s\" won't be expanded."), filename); + globerr = glob(filename, GLOB_NOCHECK, NULL, &globbuf); +#endif + if (globerr != 0 && globerr != GLOB_NOMATCH) xerr(EXIT_FAILURE, _("glob failed"));