Subject: Re: make print-PLIST and pkg_add use different quote/escape conventions
To: None <>
From: J Chapman Flack <>
List: tech-pkg
Date: 03/13/2005 17:10:12
> OK, make it:
> @exec ${MKDIR} '%D/.../brown&sharpe'
> Maybe someone finds time to fix print-PLIST...

Essentially my original point, but in greater depth it is this:

1.  The pkg_install tools should _document_ the lexical rules that apply
    to PLIST directives such as @exec.  That could be as simple as saying
    "the line following @exec is passed to system() after expanding %D"
    with a few more details to be spelled out.  Is there any way to
    continue the line, and so on.  system(3) explicitly specifies sh(1)
    as the command interpreter, so that determines the relevant lexical

2.  THEN (when the lexical rules are documented) it becomes possible for
    print-PLIST to be corrected to match them.  The simplest correct
    quoting for sh(1) lexical rules requires two steps:
    a. replace every ' with the four character sequence '\''
    b. enclose the resulting string in ' '

Of course sh(1) quoting is complex enough that there are numerous other
algorithmic ways to quote that are equally correct (if harder to prove
correct), plus far too many ways that are even harder to prove correct
because they're not.  ;)  I know there's a :Q variable modifier in make
that intends to be correct, though I've not tried to prove it....