Module Name: src Committed By: sjg Date: Tue May 9 20:53:23 UTC 2023
Modified Files: src/usr.bin/make: make.1 var.c Log Message: make: :mtime=error throw error on stat(2) failure Sometimes we want fatal error if stat fails on the presumed pathname. To generate a diff of this commit: cvs rdiff -u -r1.364 -r1.365 src/usr.bin/make/make.1 cvs rdiff -u -r1.1051 -r1.1052 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.364 src/usr.bin/make/make.1:1.365 --- src/usr.bin/make/make.1:1.364 Tue May 9 20:14:27 2023 +++ src/usr.bin/make/make.1 Tue May 9 20:53:23 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.364 2023/05/09 20:14:27 sjg Exp $ +.\" $NetBSD: make.1,v 1.365 2023/05/09 20:53:23 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -1522,6 +1522,13 @@ If fails; use .Ar timestamp or current time. +If +.Ar timestamp +is set to +.Ql error , +then +.Xr stat 2 +failure will cause an error. .It Cm \&:tA Attempts to convert the value to an absolute path using .Xr realpath 3 . Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1051 src/usr.bin/make/var.c:1.1052 --- src/usr.bin/make/var.c:1.1051 Tue May 9 20:14:27 2023 +++ src/usr.bin/make/var.c Tue May 9 20:53:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1052 2023/05/09 20:53:23 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1052 2023/05/09 20:53:23 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2841,6 +2841,7 @@ ApplyModifier_Mtime(const char **pp, Mod Expr *expr = ch->expr; const char *args, *mod = *pp; struct stat st; + bool error = false; int i = -1; if (!ModMatchEq(mod, "mtime", ch)) @@ -2849,13 +2850,20 @@ ApplyModifier_Mtime(const char **pp, Mod args = *pp; if (args[0] == '=') { args++; - if (!TryParseIntBase0(&args, &i)) - return AMR_BAD; + if (!TryParseIntBase0(&args, &i)) { + if (strncmp(args, "error", 5) == 0) { + error = true; + args += 5; + } else + return AMR_BAD; + } *pp = args; } if (!ModChain_ShouldEval(ch)) return AMR_OK; if (stat(Expr_Str(expr), &st) < 0) { + if (error) + return AMR_BAD; if (i < 0) time(&st.st_mtime); else