Document the rather suprising behavior with ' inside action rules.
To prevent issues with odd shell characters appearing in, a surprising shell feature is used. Document it and a workaround for it. Differential Revision: https://reviews.freebsd.org/D26723
This commit is contained in:
parent
e694696956
commit
eb93b08fe0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366661
@ -40,7 +40,7 @@
|
|||||||
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
.\" SOFTWARE.
|
.\" SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd August 18, 2020
|
.Dd October 12, 2020
|
||||||
.Dt DEVD.CONF 5
|
.Dt DEVD.CONF 5
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -662,6 +662,59 @@ For example:
|
|||||||
// is a new comment, even though it is logically
|
// is a new comment, even though it is logically
|
||||||
// part of the previous comment.
|
// part of the previous comment.
|
||||||
.Ed
|
.Ed
|
||||||
|
.Ss Notes on Variable Expansion
|
||||||
|
To prevent issues with special shell characters, the following happens for each
|
||||||
|
variable
|
||||||
|
.Ic $foo .
|
||||||
|
.Bl -enum
|
||||||
|
.It
|
||||||
|
The characters
|
||||||
|
.Dq $'
|
||||||
|
are inserted.
|
||||||
|
.It
|
||||||
|
The string
|
||||||
|
.Dq $foo
|
||||||
|
is removed.
|
||||||
|
.It
|
||||||
|
The value of the
|
||||||
|
.Ic foo
|
||||||
|
variable is inserted into the buffer with all single quote characters
|
||||||
|
prefixed by a backslash.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
See
|
||||||
|
.Xr sh 1
|
||||||
|
for what this construct means.
|
||||||
|
It is safe in all context, except one: inside single quotes.
|
||||||
|
If foo=meta and bar=var, then a rule like the following:
|
||||||
|
.Bd -literal -offset indent -compact
|
||||||
|
action "echo '$foo $bar'";
|
||||||
|
.Ed
|
||||||
|
will be presented to the shell via
|
||||||
|
.Xr system 3
|
||||||
|
as
|
||||||
|
.Bd -literal -offset indent -compact
|
||||||
|
echo '$'meta' $'var''
|
||||||
|
.Ed
|
||||||
|
which produces the following output:
|
||||||
|
.Bd -literal -offset indent -compact
|
||||||
|
$meta $var
|
||||||
|
.Ed
|
||||||
|
as its output.
|
||||||
|
This is an unanticipated result.
|
||||||
|
A future version of this software will change this behavior.
|
||||||
|
Users are discouraged from using single quotes inside
|
||||||
|
.Ic action
|
||||||
|
value without due care.
|
||||||
|
.Pp
|
||||||
|
The above should be written as
|
||||||
|
.Bd -literal -offset indent -compact
|
||||||
|
action "echo $foo' '$bar"
|
||||||
|
.Ed
|
||||||
|
to produce a single argument to echo.
|
||||||
|
Given the above expansion, juxtaposing bare variables with
|
||||||
|
single quote expressions will produce the right output,
|
||||||
|
regardless of the value of the variable.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -width ".Pa /etc/devd.conf" -compact
|
.Bl -tag -width ".Pa /etc/devd.conf" -compact
|
||||||
.It Pa /etc/devd.conf
|
.It Pa /etc/devd.conf
|
||||||
@ -733,6 +786,9 @@ detach 0 {
|
|||||||
The installed
|
The installed
|
||||||
.Pa /etc/devd.conf
|
.Pa /etc/devd.conf
|
||||||
has many additional examples.
|
has many additional examples.
|
||||||
|
.Sh BUGS
|
||||||
|
The variable expansion's interaction with single quotes is
|
||||||
|
suboptimal and surprising.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr cam 4 ,
|
.Xr cam 4 ,
|
||||||
.Xr coretemp 4 ,
|
.Xr coretemp 4 ,
|
||||||
|
Loading…
Reference in New Issue
Block a user