Finding $pidfile from a conf file (Was: Re: conf/153460: devd(8) cannot be restarted correctly via /etc/rc.d script)

Jilles Tjoelker jilles at stack.nl
Sat Apr 23 10:42:33 UTC 2011


On Thu, Apr 21, 2011 at 05:49:05PM -0700, Doug Barton wrote:
> On 04/21/2011 16:28, Jilles Tjoelker wrote:
> >> 		line="/${line%%[\"\;]*}"

> > The meaning of this line depends on the version of sh(1). The correct
> > interpretation, used by sh in 9-current and most other shells, is to
> > strip from the first double-quote or semicolon onwards. However, sh in
> > older FreeBSD versions will strip from the first backslash, double-quote
> > or semicolon onwards.

> > If the 9-current behaviour is desired for all FreeBSD versions, use:
> > 		line=/${line%%[\"\;]*}

> I think it's incredibly unlikely that there would actually be a
> backslash in the text, and even if there was, it should be ok to strip
> from there.

Even if there is, it seems bad if this differs between 8.x and 9.x.

> In the almost equally unlikely even that there is a space in the path
> name of the pid file, I think the quotes are safer, and future-proof.

Assignments are not subject to word splitting anyway, so this is not an
issue.

The only reasons to quote expansions in assignments are paranoia
(because in most other contexts they should be quoted to avoid
splitting) and "$*" (because POSIX is clear about v="$*" but not about
v=$*).

If a variable is assigned as it is made local, readonly or exported,
that is syntactically not an assignment so quotes are required.

Furthermore, note that the line above
		line=${line#*/}
does not have the quotes either.

-- 
Jilles Tjoelker


More information about the freebsd-rc mailing list