For +=/-=, add . and / to convenience characters

sysrc(8) supports key+=value and key-=value, but can be told what the
delimiter is by being passed as char1 (e.g., "sysrc key+=",value" to use a
comma as the delimiter instead of space). For convenience, if the first char
is alpha-numeric, it is assumed you wanted whitespace as the delimiter.

However, if you naively (as I just did) execute:
	sysrc rc_conf_files+=/etc/rc.conf.other
the result is unexpected.

This commit makes `.' and `/' in-addition to alpha-numeric first-characters
to cause the default of whitespace to be used as the delimiter. This also
means that you can no longer use these as a delimiter.
This commit is contained in:
Devin Teske 2016-02-02 22:18:43 +00:00
parent 613d7da7d5
commit 6350eae8e4
2 changed files with 10 additions and 2 deletions

View File

@ -790,7 +790,7 @@ while [ $# -gt 0 ]; do
delim="${add%"${add#?}"}" # first character
oldIFS="$IFS"
case "$delim" in
""|[$IFS]|[a-zA-Z0-9]) delim=" " ;;
""|[$IFS]|[a-zA-Z0-9./]) delim=" " ;;
*) IFS="$delim"
esac
new="$before"
@ -812,7 +812,7 @@ while [ $# -gt 0 ]; do
delim="${remove%"${remove#?}"}" # first character
oldIFS="$IFS"
case "$delim" in
""|[$IFS]|[a-zA-Z0-9]) delim=" " ;;
""|[$IFS]|[a-zA-Z0-9./]) delim=" " ;;
*) IFS="$delim"
esac
new=

View File

@ -275,6 +275,10 @@ it is added
.Pp
For convenience, if the first character is alpha-numeric
.Pq letters A-Z, a-z, or numbers 0-9 ,
dot
.Pq Li . ,
or slash
.Pq Li / ,
.Nm
uses the default setting of whitespace as separator.
For example, the above and below statements are equivalent since
@ -329,6 +333,10 @@ it is removed
.Pp
For convenience, if the first character is alpha-numeric
.Pq letters A-Z, a-z, or numbers 0-9 ,
dot
.Pq Li . ,
or slash
.Pq Li / ,
.Nm
uses the default setting of whitespace as separator.
For example, the above and below statements are equivalent since