safe_set treat ':' and '#' differently

Treat '#' as a comment anywhere,
but ':' only at start of line.
This commit is contained in:
Simon J. Gerraty
2026-04-22 09:37:35 -07:00
parent e3e8ec2ab6
commit 566cc00581
+2 -2
View File
@@ -1,6 +1,6 @@
: :
# RCSid: # RCSid:
# $Id: safe_eval.sh,v 1.27 2026/04/22 16:11:57 sjg Exp $ # $Id: safe_eval.sh,v 1.28 2026/04/22 16:36:32 sjg Exp $
# #
# @(#) Copyright (c) 2023-2026 Simon J. Gerraty # @(#) Copyright (c) 2023-2026 Simon J. Gerraty
# #
@@ -32,7 +32,7 @@ fi
# "xtras" should be used with caution and cannot include ';' # "xtras" should be used with caution and cannot include ';'
# #
safe_set() { safe_set() {
${SED:-sed} 's/^[ ]*//;s/^[:#].*//;/^[A-Za-z_][A-Za-z0-9_]*=/!d;s;[^A-Za-z0-9_. "'"$1"'$,/=:+-];_;g' ${SED:-sed} 's/^[ ]*//;s/[ ]*#.*//;s/^:.*//;/^[A-Za-z_][A-Za-z0-9_]*=/!d;s;[^A-Za-z0-9_. "'"$1"'$,/=:+-];_;g'
} }
## ##