Page MenuHomeFreeBSD

D61584.1794863148.diff
No OneTemporary

Authored By
Unknown
Size
18 KB
Referenced Files
None
Subscribers
None

D61584.1794863148.diff

diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc
--- a/usr.sbin/sysrc/sysrc
+++ b/usr.sbin/sysrc/sysrc
@@ -16,7 +16,7 @@
#
# Version information
#
-SYSRC_VERSION="7.3.1 Oct-17,2026"
+SYSRC_VERSION="7.4 Nov-14,2026"
#
# Options
@@ -31,6 +31,7 @@
LIST_SERVICE_CONFS=
LIST_CONFS=
QUIET=
+RAW=
ROOTDIR=
SERVICE=
SHOW_ALL=
@@ -125,12 +126,14 @@
"Show only variable names, not their values."
f_err "$optfmt" "-q" \
"Quiet. Disable verbose and hide certain errors."
+ f_err "$optfmt" "-r" \
+ "Show raw, unexpanded value(s)."
+ f_err "$optfmt" "-R dir" \
+ "Operate within the root directory \`dir' rather than \`/'."
f_err "$optfmt" "-s name" \
"Process additional \`rc.conf.d' entries for service name."
f_err "$optfmt" "" \
"Ignored if \`-f file' is given."
- f_err "$optfmt" "-R dir" \
- "Operate within the root directory \`dir' rather than \`/'."
f_err "$optfmt" "-v" \
"Verbose. Print the pathname of the specific rc.conf(5)"
f_err "$optfmt" "" \
@@ -216,7 +219,7 @@
#
# Process command-line flags
#
-while getopts aAcdDeEf:Fhij:lLnNqR:s:vxX flag; do
+while getopts aAcdDeEf:Fhij:lLnNqrR:s:vxX flag; do
case "$flag" in
a) SHOW_ALL=${SHOW_ALL:-1} ;;
A) SHOW_ALL=2 ;;
@@ -237,6 +240,7 @@
n) SHOW_NAME= ;;
N) SHOW_VALUE= ;;
q) QUIET=1 VERBOSE= ;;
+ r) RAW=1 ;;
R) [ "$OPTARG" ] ||
die "%s: Missing or null argument to \`-R' flag" "$pgm"
ROOTDIR="$OPTARG" ;;
@@ -578,8 +582,9 @@
EXCEPT="$EXCEPT|DELETE|SHOW_ALL|SHOW_EQUALS|SHOW_NAME|DEFAULT"
EXCEPT="$EXCEPT|SHOW_VALUE|SHOW_FILE|VERBOSE|RC_CONFS|SERVICE"
EXCEPT="$EXCEPT|pgm|SUCCESS|FAILURE|CHECK_ONLY|EXISTING_ONLY"
- EXCEPT="$EXCEPT|LIST_CONFS|LIST_SERVICE_CONFS"
+ EXCEPT="$EXCEPT|LIST_CONFS|LIST_SERVICE_CONFS|RAW"
EXCEPT="$EXCEPT|f_sysrc_desc_awk|f_sysrc_delete_awk"
+ EXCEPT="$EXCEPT|f_sysrc_get_raw_awk"
#
# Clean the environment (except for our required variables)
@@ -662,7 +667,8 @@
fi
echo "${SHOW_NAME:+$NAME$SEP}$(
- f_sysrc_get "$NAME" )${SHOW_EQUALS:+\"}"
+ f_sysrc_get${RAW:+_raw} "$NAME"
+ )${SHOW_EQUALS:+\"}"
done
)
@@ -723,7 +729,7 @@
#
case "$mode" in
APPEND)
- before=$( f_sysrc_get "$NAME" )
+ before=$( f_sysrc_get${RAW:+_raw} "$NAME" )
add="${1#*=}"
delim="${add%"${add#?}"}" # first character
oldIFS="$IFS"
@@ -745,7 +751,7 @@
[ "$SHOW_FILE" ] && before=$( f_sysrc_find "$NAME" )
;;
REMOVE)
- before=$( f_sysrc_get "$NAME" )
+ before=$( f_sysrc_get${RAW:+_raw} "$NAME" )
remove="${1#*=}"
delim="${remove%"${remove#?}"}" # first character
oldIFS="$IFS"
@@ -769,6 +775,8 @@
*) # ASSIGN
if [ "$SHOW_FILE" ]; then
before=$( f_sysrc_find "$NAME" )
+ elif [ "$CHECK_ONLY$RAW" ]; then
+ before=$( f_sysrc_get_raw "$NAME" )
else
before=$( f_sysrc_get "$NAME" )
fi
@@ -813,6 +821,10 @@
if [ ! "$QUIET" ]; then
if [ "$SHOW_FILE" ]; then
after=$( f_sysrc_find "$NAME" )
+ elif [ "$RAW" ]; then
+ after=$(
+ f_sysrc_get_raw "$NAME"
+ )
else
after=$( f_sysrc_get "$NAME" )
fi
@@ -886,7 +898,8 @@
echo "$NAME"
else
echo "${SHOW_NAME:+$NAME$SEP}$(
- f_sysrc_get "$NAME" )${SHOW_EQUALS:+\"}"
+ f_sysrc_get${RAW:+_raw} "$NAME"
+ )${SHOW_EQUALS:+\"}"
fi
esac
shift 1
diff --git a/usr.sbin/sysrc/sysrc.8 b/usr.sbin/sysrc/sysrc.8
--- a/usr.sbin/sysrc/sysrc.8
+++ b/usr.sbin/sysrc/sysrc.8
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
-.\" Copyright (c) 2011-2016 Devin Teske
+.\" Copyright (c) 2011-2026 Devin Teske
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 3, 2022
+.Dd November 15, 2026
.Dt SYSRC 8
.Os
.Sh NAME
@@ -33,14 +33,14 @@
.Nd safely edit system rc files
.Sh SYNOPSIS
.Nm
-.Op Fl cdDeEFhinNqvx
+.Op Fl cdDeEFhinNqrvx
.Op Fl s Ar name
.Op Fl f Ar file
.Op Fl j Ar jail | Fl R Ar dir
.Ar name Ns Op Ns Oo +|- Oc Ns = Ns Ar value
.Ar ...
.Nm
-.Op Fl cdDeEFhinNqvx
+.Op Fl cdDeEFhinNqrvx
.Op Fl s Ar name
.Op Fl f Ar file
.Op Fl j Ar jail | Fl R Ar dir
@@ -147,6 +147,8 @@
and one or more
.Ar name
arguments, provide only exit status and no output.
+.It Fl r
+Show raw, unexpected value(s).
.It Fl R Ar dir
Operate within the root directory
.Sq Ar dir
diff --git a/usr.sbin/sysrc/sysrc.subr b/usr.sbin/sysrc/sysrc.subr
--- a/usr.sbin/sysrc/sysrc.subr
+++ b/usr.sbin/sysrc/sysrc.subr
@@ -294,6 +294,488 @@
)
}
+# f_sysrc_get_raw $varname
+#
+# Without expanding the value (e.g., in the case of `-c' check), get a system
+# configuration setting from the collection of system-configuration files (in
+# order: /etc/defaults/rc.conf /etc/rc.conf and /etc/rc.conf.local)
+#
+# Much of the complexity here is to handle things like:
+#
+# 1. Even-vs-Odd backslash count
+# a. preceding things like ", ', $, `, NL, etc.
+# 2. Single-vs-Double quoting
+# 3. Dollar quoting
+# a. $'\t' to expand escapes (in example, a real tab)
+# b. $"File not found." i18n translation; for example:
+# export LC_ALL=es_ES.UTF-8
+# export TEXTDOMAIN=bash
+# export TEXTDOMAINDIR=/usr/local/share/locale
+# bash -c 'echo $"%s: not found"' -> %s: no encontrado
+# NB: /bin/sh has no *.mo files but the syntax should still be supported
+# 4. Compound quoting
+# a. single-with-double or vice-versa ["a"'b' or 'c'"d"]
+# b. bare-with-quoted [abc\ '123' or "def"\ 456]
+# c. joined arithmetic ["foo"$(( 1 + 1 ))]
+# d. joined command substitutions ["bar"`baz` or "bar"$( baz )]
+# 5. Parameter expansions
+# a. Without quotes [${abc#123}]
+# b. With quotes [${foo#"bar"} or ${bar#'baz'}]
+# c. Quoted with same quotes ["${foo#"bar"}"]
+# d. Single-quoted literal compound ['${foo#'bar'}']
+# e. With whitespace [${foo#bar baz}]
+# f. Nested [${foo#`bar ${baz}`}]
+# 6. Newlines and line continuations
+# a. Inside single-quotes
+# b. Inside double-quotes
+# c. Unquoted using a trailing backslash at the end of the line
+# 7. Multi-assignment lines [foo=bar bar=baz]
+# a. With various flavors of quoting or joined statements
+# [foo="abc"`def 123`${ghi#"456"} bar=baz]
+# [foo=abc;bar=baz]
+# NB: Only works to return correct value if requested variable
+# is the first word assignment (e.g., asking for foo).
+# 8. Combinations and mixtures of the above
+#
+# NOTE: Additional shell parameter-expansion formats are supported. For
+# example, passing an argument of "hostname%%.*" (properly quoted) will
+# return the hostname up to (but not including) the first `.' (see sh(1),
+# "Parameter Expansion" for more information on additional formats).
+#
+f_sysrc_get_raw_awk='
+# Variables that should be defined on the invocation line:
+# -v varname="varname"
+#
+BEGIN {
+ # NB: Should be same regex as f_sysrc_find()
+ regex = sprintf("^[[:space:]]*%s=", varname)
+ value = ""
+}
+
+#
+# Quote-remove one assignment word starting at start
+# NB: Supports varname=value othervar=othervalue ...
+#
+function read_value(start, out, q, ch)
+{
+ q_i = start
+ q_at_nl = 0
+ sq = "\047"
+ out = ""
+ q = 0
+ while (next_char()) {
+ ch = q_c
+ if ( q == 1 ) {
+ if ( ch == sq ) {
+ q = 0
+ continue
+ }
+ out = out ch
+ continue
+ }
+ if ( q == 2 ) {
+ if ( ch == "\\" ) {
+ if ( !next_char() ) {
+ out = out "\\"
+ break
+ }
+ ch = q_c
+ if ( ch == "\n" ) continue
+ if ( ch == "$" || ch == "`" ||
+ ch == "\"" || ch == "\\" )
+ out = out ch
+ else
+ out = out "\\" ch
+ continue
+ }
+ if ( ch == "\"" ) {
+ q = 0
+ continue
+ }
+ if ( ch == "$" ) {
+ out = out read_dollar(1)
+ continue
+ }
+ if ( ch == "`" ) {
+ out = out read_bquote()
+ continue
+ }
+ out = out ch
+ continue
+ }
+ if ( ch == sq ) {
+ q = 1
+ continue
+ }
+ if ( ch == "\"" ) {
+ q = 2
+ continue
+ }
+ if ( ch == "\\" ) {
+ if ( !next_char() ) {
+ out = out "\\"
+ break
+ }
+ if ( q_c == "\n" ) continue
+ out = out q_c
+ continue
+ }
+ if ( word_end(ch) ) break
+ if ( ch == "$" ) {
+ out = out read_dollar()
+ continue
+ }
+ if ( ch == "`" ) {
+ out = out read_bquote()
+ continue
+ }
+ out = out ch
+ }
+ return out
+}
+
+function word_end(ch)
+{
+ if ( ch == "\n" || ch == " " || ch == "\t" ) return 1
+ if ( ch == ";" || ch == "&" || ch == "|" ) return 1
+ if ( ch == "<" || ch == ">" || ch == "(" || ch == ")" ) return 1
+ return 0
+}
+
+function next_char( r)
+{
+ if ( q_i <= length($0) ) {
+ q_c = substr($0, q_i, 1)
+ q_i++
+ return 1
+ }
+ if ( q_at_nl ) {
+ r = getline
+ if ( r <= 0 ) return 0
+ q_at_nl = 0
+ if ( length($0) == 0 ) {
+ q_c = "\n"
+ q_at_nl = 1
+ q_i = 1
+ return 1
+ }
+ q_c = substr($0, 1, 1)
+ q_i = 2
+ return 1
+ }
+ q_c = "\n"
+ q_at_nl = 1
+ return 1
+}
+
+function peek_char()
+{
+ if ( q_i <= length($0) ) return substr($0, q_i, 1)
+ if ( q_at_nl ) return ""
+ return "\n"
+}
+
+# Copy one expansion without running it. inq means the $ is already
+# inside double quotes; a dollar quote is kept whole only when unquoted.
+function read_dollar(inq, p)
+{
+ p = peek_char()
+ if ( p == "(" ) {
+ next_char()
+ if ( peek_char() == "(" ) {
+ next_char()
+ return read_arith()
+ }
+ return read_cmd()
+ }
+ if ( p == "{" ) {
+ next_char()
+ return read_param()
+ }
+ if ( !inq && (p == sq || p == "\"") )
+ return read_dolquote()
+ return "$"
+}
+
+# Dollar-single or dollar-double quote; marks kept, escapes left as written
+function read_dolquote( out, qch, ch)
+{
+ qch = peek_char()
+ next_char()
+ out = "$" qch
+ while (next_char()) {
+ ch = q_c
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ out = out ch
+ if ( ch == qch ) break
+ }
+ return out
+}
+
+function read_cmd( out, depth, q, ch)
+{
+ out = "$("
+ depth = 1
+ q = 0
+ while (depth > 0 && next_char()) {
+ ch = q_c
+ if ( q == 1 ) {
+ out = out ch
+ if ( ch == sq ) q = 0
+ continue
+ }
+ if ( q == 2 ) {
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ out = out ch
+ if ( ch == "\"" ) q = 0
+ continue
+ }
+ if ( ch == sq ) {
+ out = out ch
+ q = 1
+ continue
+ }
+ if ( ch == "\"" ) {
+ out = out ch
+ q = 2
+ continue
+ }
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ if ( ch == "$" ) {
+ out = out read_dollar()
+ continue
+ }
+ if ( ch == "`" ) {
+ out = out read_bquote()
+ continue
+ }
+ if ( ch == "(" ) depth++
+ else if ( ch == ")" ) depth--
+ out = out ch
+ }
+ return out
+}
+
+function read_param( out, q, ch)
+{
+ out = "${"
+ q = 0
+ while (next_char()) {
+ ch = q_c
+ if ( q == 1 ) {
+ out = out ch
+ if ( ch == sq ) q = 0
+ continue
+ }
+ if ( q == 2 ) {
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ out = out ch
+ if ( ch == "\"" ) q = 0
+ continue
+ }
+ if ( ch == sq ) {
+ out = out ch
+ q = 1
+ continue
+ }
+ if ( ch == "\"" ) {
+ out = out ch
+ q = 2
+ continue
+ }
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ if ( ch == "$" ) {
+ out = out read_dollar()
+ continue
+ }
+ if ( ch == "`" ) {
+ out = out read_bquote()
+ continue
+ }
+ out = out ch
+ if ( ch == "}" ) break
+ }
+ return out
+}
+
+function read_arith( out, depth, ch)
+{
+ out = "$(("
+ depth = 0
+ while (next_char()) {
+ ch = q_c
+ if ( ch == "$" ) {
+ out = out read_dollar()
+ continue
+ }
+ if ( ch == "`" ) {
+ out = out read_bquote()
+ continue
+ }
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ if ( ch == "(" ) {
+ depth++
+ out = out ch
+ continue
+ }
+ if ( ch == ")" ) {
+ if ( depth > 0 ) {
+ depth--
+ out = out ch
+ continue
+ }
+ out = out ch
+ if ( peek_char() == ")" ) {
+ next_char()
+ out = out q_c
+ break
+ }
+ continue
+ }
+ out = out ch
+ }
+ return out
+}
+
+function read_bquote( out, q, ch, p)
+{
+ out = "`"
+ q = 0
+ while (next_char()) {
+ ch = q_c
+ if ( q == 1 ) {
+ out = out ch
+ if ( ch == sq ) q = 0
+ continue
+ }
+ if ( q == 2 ) {
+ if ( ch == "\\" ) {
+ out = out ch
+ if ( !next_char() ) break
+ out = out q_c
+ continue
+ }
+ out = out ch
+ if ( ch == "\"" ) q = 0
+ continue
+ }
+ if ( ch == sq ) {
+ out = out ch
+ q = 1
+ continue
+ }
+ if ( ch == "\"" ) {
+ out = out ch
+ q = 2
+ continue
+ }
+ if ( ch == "\\" ) {
+ p = peek_char()
+ out = out ch
+ if ( p == "$" || p == "`" ||
+ p == "\\" || p == "\n" ) {
+ if ( !next_char() ) break
+ out = out q_c
+ }
+ continue
+ }
+ if ( ch == "`" ) {
+ out = out ch
+ break
+ }
+ if ( ch == "$" ) {
+ out = out read_dollar()
+ continue
+ }
+ out = out ch
+ }
+ return out
+}
+
+/^[[:space:]]*(#|$)/ { next } # skip blank lines and comments
+match($0, regex) { value = read_value(RSTART + RLENGTH) }
+
+END { printf "%s\n", value }
+'
+f_sysrc_get_raw()
+{
+ local varname="${1%%[!$VALID_VARNAME_CHARS]*}"
+ local paramexp="${1#"$varname"}"
+ local file value
+
+ # Taint-check variable name
+ case "$varname" in
+ [0-9]*)
+ # Don't expand possible positional parameters
+ return $FAILURE ;;
+ *)
+ [ "$varname" ] || return $FAILURE
+ esac
+
+ if ! file=$( f_sysrc_find "$varname" ); then
+ #
+ # Like f_sysrc_get() given an unset variable, return no value
+ # with success unless paramexp specifically requests error
+ #
+ case "$paramexp" in
+ "?"*)
+ # Same exit status as: f_sysrc_get 'varname?'
+ return 2 ;;
+ esac
+ echo
+ return $SUCCESS
+ fi
+
+ #
+ # To get the raw value, we cannot simply source the file,
+ # we must instead read the file
+ #
+ value=$( awk -v varname="$varname" "$f_sysrc_get_raw_awk" "$file" )
+
+ #
+ # This must be the last functional line for the function to preserve
+ # the return status from formats such as "varname:?" (see "Parameter
+ # Expansion" in sh(1) for more information).
+ #
+ # NB: The parameter expansion "varname?" cannot work here because if
+ # f_sysrc_find() did not find a setting, we have not reached this point
+ # but instead returned error status. So if we reach here, that means we
+ # already know the variable is set. Parameter expansion "varname:?"
+ # does still have meaning to test that the value is non-NULL.
+ #
+ eval printf "'%s\\n'" '"${value'"$paramexp"'}"' 2> /dev/null
+}
+
# f_sysrc_service_configs [-a|-p] $name [$var_to_set]
#
# Get a list of optional `rc.conf.d' entries sourced by system `rc.d' script
diff --git a/usr.sbin/sysrc/tests/sysrc_test.sh b/usr.sbin/sysrc/tests/sysrc_test.sh
--- a/usr.sbin/sysrc/tests/sysrc_test.sh
+++ b/usr.sbin/sysrc/tests/sysrc_test.sh
@@ -262,6 +262,51 @@
sysrc -f "${SYSRC_CONF}" -c test_enable=YES test_list-=item1
}
+atf_test_case c_flag_quoting
+c_flag_quoting_head()
+{
+ atf_set "descr" "Verify -c compares raw assignment text"
+}
+c_flag_quoting_body()
+{
+ local msg
+
+ # PR 299413: the expanded value is " -J 15"
+ printf '%s\n' 'cron_flags="$cron_flags -J 15"' > "${SYSRC_CONF}"
+ msg="${SYSRC_CONF}: cron_flags: already set to"
+ msg="$msg \`\$cron_flags -J 15'"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -v -c 'cron_flags=$cron_flags -J 15'
+ msg="${SYSRC_CONF}: cron_flags: would change from"
+ msg="$msg \`\$cron_flags -J 15' to \`\$cron_flags -J 16'"
+ atf_check -s exit:1 -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -v -c 'cron_flags=$cron_flags -J 16'
+
+ # Same raw text in the other quote forms
+ printf '%s\n' "cron_flags='\$cron_flags -J 15'" > "${SYSRC_CONF}"
+ atf_check sysrc -f "${SYSRC_CONF}" -c 'cron_flags=$cron_flags -J 15'
+ printf '%s\n' 'cron_flags=$cron_flags\ -J\ 15' > "${SYSRC_CONF}"
+ atf_check sysrc -f "${SYSRC_CONF}" -c 'cron_flags=$cron_flags -J 15'
+ printf '%s\n' "cron_flags='\$cron_flags'\" -J 15\"" > "${SYSRC_CONF}"
+ atf_check sysrc -f "${SYSRC_CONF}" -c 'cron_flags=$cron_flags -J 15'
+
+ # Dollar quotes keep their quote marks
+ printf '%s\n' 'cron_flags=$"%s: file not found"' > "${SYSRC_CONF}"
+ msg="${SYSRC_CONF}: cron_flags: already set to"
+ msg="$msg \`\$\"%s: file not found\"'"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -v -c 'cron_flags=$"%s: file not found"'
+ atf_check -s exit:1 \
+ sysrc -f "${SYSRC_CONF}" -c 'cron_flags=$%s: file not found'
+ printf '%s\n' "cron_flags=\$'a\\tb'" > "${SYSRC_CONF}"
+ msg="${SYSRC_CONF}: cron_flags: already set to"
+ msg="$msg \`\$'a\\\\tb''"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -v -c "cron_flags=\$'a\\tb'"
+ atf_check -s exit:1 \
+ sysrc -f "${SYSRC_CONF}" -c 'cron_flags=$a\tb'
+}
+
atf_test_case d_flag cleanup
d_flag_head()
{
@@ -334,6 +379,61 @@
-f ${sysrc2_conf} -F test_enable test_list
}
+atf_test_case r_flag
+r_flag_head()
+{
+ atf_set "descr" "Verify -r shows raw assignment text"
+}
+r_flag_body()
+{
+ local msg
+
+ # Assignment keeps the expansion text
+ msg="test_flags: -> \$test_flags -J 15"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -r 'test_flags=$test_flags -J 15'
+ atf_check -o inline:'test_flags="$test_flags -J 15"\n' \
+ cat "${SYSRC_CONF}"
+
+ # Query expands; -r does not
+ atf_check -o inline:"test_flags: -J 15\n" \
+ sysrc -f "${SYSRC_CONF}" test_flags
+ atf_check -o inline:"test_flags: \$test_flags -J 15\n" \
+ sysrc -f "${SYSRC_CONF}" -r test_flags
+
+ # Replace the raw text
+ msg="test_flags: \$test_flags -J 15 ->"
+ msg="$msg \$test_flags -J 16"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -r 'test_flags=$test_flags -J 16'
+
+ # Append to the raw text
+ msg="test_flags: \$test_flags -J 16 ->"
+ msg="$msg \$test_flags -J 16 extra"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -r test_flags+=extra
+ atf_check -o inline:'test_flags="$test_flags -J 16 extra"\n' \
+ cat "${SYSRC_CONF}"
+
+ # Appending a token already present does not duplicate it
+ msg="test_flags: \$test_flags -J 16 extra ->"
+ msg="$msg \$test_flags -J 16 extra"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -r test_flags+=extra
+
+ # Subtract a token; the unexpanded name stays
+ msg="test_flags: \$test_flags -J 16 extra ->"
+ msg="$msg \$test_flags -J 16"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -r test_flags-=extra
+
+ # Drop $test_flags. A leading word keeps the space delimiter
+ msg="test_flags: \$test_flags -J 16 -> -J 16"
+ atf_check -o inline:"$msg\n" \
+ sysrc -f "${SYSRC_CONF}" -r 'test_flags-=x $test_flags'
+ atf_check -o inline:'test_flags="-J 16"\n' cat "${SYSRC_CONF}"
+}
+
atf_init_test_cases()
{
atf_add_test_case check_variable
@@ -345,7 +445,9 @@
atf_add_test_case a_flag
atf_add_test_case A_flag
atf_add_test_case c_flag
+ atf_add_test_case c_flag_quoting
atf_add_test_case d_flag
atf_add_test_case f_flag
atf_add_test_case F_flag
+ atf_add_test_case r_flag
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 16, 9:05 PM (19 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41787459
Default Alt Text
D61584.1794863148.diff (18 KB)

Event Timeline