From 6474f4e0b6ff0498ba8386f4c227066cec0355e7 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Fri, 15 Aug 2025 20:43:59 -0400 Subject: [PATCH] Note that user-defined functions defined in a RUN-OFF context will have RUN OFF during evaluation. --- man/remind.1.in | 6 ++++++ tests/safety.rem | 15 ++++++++++++++- tests/test.cmp | 26 +++++++++++++++++++++----- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/man/remind.1.in b/man/remind.1.in index 6900972c..f4646d2c 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -5325,6 +5325,12 @@ it is ignored and the built-in function is used. To prevent conflicts with future versions of \fBRemind\fR (which may define more built-in functions), you may wish to name all user-defined functions beginning with an underscore. +.PP +If a user-defined function is defined in a context where \fBRUN\fR is +disabled, then whenever that function is called, \fBRUN\fR will be disabled +during its evaluation, \fIeven if\fR it is called from a context where +\fBRUN\fR is enabled. + .PP To delete a user-defined function, use \fBFUNSET\fR. This takes a space-separated list of user-defined functions to delete. For diff --git a/tests/safety.rem b/tests/safety.rem index 9103c2d8..1dd8da26 100644 --- a/tests/safety.rem +++ b/tests/safety.rem @@ -11,7 +11,20 @@ RUN ON DEBUG +x set a danger(1) set b safe(1) -set b safe2(1) +set c safe2(1) + +PUSH-FUNCS safe +FSET safe(x) shell("echo this will work") +SET b safe(1) +POP-FUNCS +SET b safe(1) + +FRENAME safe gloopy +FRENAME danger bork +set a bork(1) +set b gloopy(1) +FRENAME gloopy safe +FRENAME bork danger RUN OFF set a danger(1) diff --git a/tests/test.cmp b/tests/test.cmp index 101af8a3..3848591b 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -39699,27 +39699,43 @@ shell("echo oops") => RUN disabled ../tests/safety.rem(8): [#1] Called from function `safe2' Leaving UserFN danger(1) => RUN disabled Leaving UserFN safe2(1) => RUN disabled +Entering UserFN safe(1) +shell("echo this will work") => "this will work" +Leaving UserFN safe(1) => "this will work" +Entering UserFN safe(1) +shell("echo nope") => RUN disabled +../tests/safety.rem(20): shell(): RUN disabled + ../tests/safety.rem(7): [#0] In function `safe' +Leaving UserFN safe(1) => RUN disabled +Entering UserFN bork(1) +shell("echo oops") => "oops" +Leaving UserFN bork(1) => "oops" +Entering UserFN gloopy(1) +shell("echo nope") => RUN disabled +../tests/safety.rem(25): shell(): RUN disabled + ../tests/safety.rem(7): [#0] In function `gloopy' +Leaving UserFN gloopy(1) => RUN disabled Entering UserFN danger(1) shell("echo oops") => RUN disabled -../tests/safety.rem(17): shell(): RUN disabled +../tests/safety.rem(30): shell(): RUN disabled ../tests/safety.rem(4): [#0] In function `danger' Leaving UserFN danger(1) => RUN disabled Entering UserFN safe(1) shell("echo nope") => RUN disabled -../tests/safety.rem(18): shell(): RUN disabled +../tests/safety.rem(31): shell(): RUN disabled ../tests/safety.rem(7): [#0] In function `safe' Leaving UserFN safe(1) => RUN disabled Entering UserFN safe2(1) x => 1 Entering UserFN danger(1) shell("echo oops") => RUN disabled -../tests/safety.rem(19): shell(): RUN disabled +../tests/safety.rem(32): shell(): RUN disabled ../tests/safety.rem(4): [#0] In function `danger' ../tests/safety.rem(8): [#1] Called from function `safe2' Leaving UserFN danger(1) => RUN disabled Leaving UserFN safe2(1) => RUN disabled nooooo.... -../tests/safety.rem(28): shell(): RUN disabled - ../tests/safety.rem(24): [#0] In function `subst_b' +../tests/safety.rem(41): shell(): RUN disabled + ../tests/safety.rem(37): [#0] In function `subst_b' today nooooo....