git: b0ada425efb3 - main - safe_eval allow : and + in values
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 26 May 2025 03:06:52 UTC
The branch main has been updated by sjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=b0ada425efb3fb1b744d66bd1d0c1bbd5a7f25e6
commit b0ada425efb3fb1b744d66bd1d0c1bbd5a7f25e6
Author: Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2025-05-26 03:05:53 +0000
Commit: Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2025-05-26 03:06:47 +0000
safe_eval allow : and + in values
---
libexec/rc/safe_eval.sh | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libexec/rc/safe_eval.sh b/libexec/rc/safe_eval.sh
index d03eacbdff72..8aaddcaf2176 100644
--- a/libexec/rc/safe_eval.sh
+++ b/libexec/rc/safe_eval.sh
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-2-Clause
# RCSid:
-# $Id: safe_eval.sh,v 1.20 2024/08/16 00:57:58 sjg Exp $
+# $Id: safe_eval.sh,v 1.24 2025/05/23 21:34:54 sjg Exp $
#
# @(#) Copyright (c) 2023-2024 Simon J. Gerraty
#
@@ -17,6 +17,17 @@
_SAFE_EVAL_SH=:
+# does local *actually* work?
+local_works() {
+ local _fu
+}
+
+if local_works > /dev/null 2>&1; then
+ _local=local
+else
+ _local=:
+fi
+
##
# safe_set
#
@@ -24,7 +35,7 @@ _SAFE_EVAL_SH=:
# any non-alphanumeric chars are replaced with '_'
#
safe_set() {
- ${SED:-sed} 's/[ ]*#.*//;/^[A-Za-z_][A-Za-z0-9_]*=/!d;s;[^A-Za-z0-9_. "$,/=-];_;g'
+ ${SED:-sed} 's/[ ]*#.*//;/^[A-Za-z_][A-Za-z0-9_]*=/!d;s;[^A-Za-z0-9_. "$,/=:+-];_;g'
}
##
@@ -54,7 +65,7 @@ safe_eval_export() {
# feed all "file" that exist to safe_eval
#
safe_dot() {
- eval ${local:-:} ef ex f rc
+ eval $_local ef ex f rc
ef=
ex=
rc=1