From 5a7bd2c196b5f1bd22db2153e471c5d09252dbf4 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 3 Aug 2020 08:31:23 +0100 Subject: [PATCH] Further fix 'command -p' (re: c9ccee86) This fixes 'command -p' for systems where getconf(1) lives somewhere other than in /bin or /usr/bin, i.e. NixOS. src/lib/libast/comp/conf.tab: - To determine the default path value for AST 'getconf PATH' and 'command -p', compile a small C program to get the correct local default path value (_CS_PATH) from the operating system so it gets hardcoded in the ksh binary. This eliminates the need to to invoke 'getconf PATH' to get this value, which fixes a catch-22 problem on systems where getconf(1) exists somewhere other than /bin or /usr/bin. --- src/lib/libast/comp/conf.tab | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lib/libast/comp/conf.tab b/src/lib/libast/comp/conf.tab index 2dc05e039..0f8368f97 100644 --- a/src/lib/libast/comp/conf.tab +++ b/src/lib/libast/comp/conf.tab @@ -368,7 +368,23 @@ PAGESIZE POSIX SC 1 MU PAGESIZE PAGE_SIZE 4096 cc{ } PAGE_SIZE POSIX SC 1 MU _AST_PAGESIZE PASS_MAX SVID SC 1 CDLMU 8 -PATH POSIX CS 1 CMU "/bin:/usr/bin" +PATH POSIX CS 1 MU cc{ + #include + #include + int main() + { + size_t length = confstr(_CS_PATH, 0, 0); + if(!length) + printf("\\"/bin:/usr/bin\\""); + else + { + char path[length]; + confstr(_CS_PATH, path, length); + printf("\\"%s\\"", path); + } + return 0; + } +} PATH_MAX POSIX PC 1 CDLMUX MAXPATHLEN 1024 PBS POSIX SC 2 FUW PBS_ACCOUNTING POSIX SC 2 FUW