Date: Fri, 10 Apr 2026 16:12:15 +0000 From: Simon J. Gerraty <sjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: de9fe28ab847 - main - Allow passing xtras to safe_set Message-ID: <69d9215f.22dd8.4790d0bc@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=de9fe28ab8476ca25a63066503f5fb40dcdd5719 commit de9fe28ab8476ca25a63066503f5fb40dcdd5719 Author: Simon J. Gerraty <sjg@FreeBSD.org> AuthorDate: 2026-04-10 16:08:02 +0000 Commit: Simon J. Gerraty <sjg@FreeBSD.org> CommitDate: 2026-04-10 16:11:21 +0000 Allow passing xtras to safe_set This allows safe_set to be leveraged in other contexts where additional chars like '*' or '!' or even '\[\]' need to be preserved in the result. --- libexec/rc/safe_eval.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libexec/rc/safe_eval.sh b/libexec/rc/safe_eval.sh index 6c23b4c98218..e12b17c787d2 100644 --- a/libexec/rc/safe_eval.sh +++ b/libexec/rc/safe_eval.sh @@ -1,8 +1,8 @@ : # RCSid: -# $Id: safe_eval.sh,v 1.25 2025/08/07 22:13:03 sjg Exp $ +# $Id: safe_eval.sh,v 1.26 2026/04/10 16:03:39 sjg Exp $ # -# @(#) Copyright (c) 2023-2024 Simon J. Gerraty +# @(#) Copyright (c) 2023-2026 Simon J. Gerraty # # SPDX-License-Identifier: BSD-2-Clause # @@ -23,13 +23,16 @@ else fi ## -# safe_set +# safe_set [xtras] # # return a safe variable setting -# any non-alphanumeric chars are replaced with '_' +# any non-alphanumeric chars other than those in "xtras" +# will be replaced with '_' # +# "xtras" should be used with caution and cannot include ';' +# 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_. "'"$1"'$,/=:+-];_;g' } ##home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69d9215f.22dd8.4790d0bc>
