Skip to content

Commit 1aca27a

Browse files
committed
build: mamake: run shell actions in POSIX mode (re: 11bd592)
On QNX (at least 6.5.0), /bin/cp does not update the target file's last-modified timestamp by default, unless the POSIX_STRICT variable is exported. So, as of the referenced commit, repeated builds without that variable exported fail with "target not updated" in shell actions that rely on cp(1) to update the target's timestamp. (And before that, this issue was causing unnecessary re-execution of other shell actions.) To avoid similar issues in future, it generally seems like a good idea to set POSIX compliance mode for the shell and external commands where available. The shell is launched with argv[0]=="sh" (see line 1564), which puts several shells in POSIX mode already. But many external commands, especially the GNU versions, need an environment variable. src/cmd/INIT/mamake.c: - Unconditionally export POSIXLY_CORRECT=y. Though that is originally a GNU thing, several other systems now use it, too. - On QNX, export POSIX_STRICT=y to fix /bin/cp and avoid the described rebuild issues.
1 parent 02b5172 commit 1aca27a

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/cmd/INIT/mamake.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* coded for portability
2929
*/
3030

31-
#define RELEASE_DATE "2026-02-15"
31+
#define RELEASE_DATE "2026-02-18"
3232
static char id[] = "\n@(#)$Id: mamake (ksh 93u+m) " RELEASE_DATE " $\0\n";
3333

3434
#if _PACKAGE_ast
@@ -3009,6 +3009,15 @@ int main(int argc, char **argv)
30093009
if (state.recurse)
30103010
state.maxjobs = 0;
30113011

3012+
/*
3013+
* standards compliance for shell actions
3014+
*/
3015+
3016+
setenv("POSIXLY_CORRECT", "y", 1);
3017+
#if __QNX__
3018+
setenv("POSIX_STRICT", "y", 1); /* required for /bin/cp on QNX to update the target's last-modified date */
3019+
#endif
3020+
30123021
/*
30133022
* load the environment
30143023
*/

0 commit comments

Comments
 (0)