Portfile question (actually, tcl question)

Gerben Wierda gerben.wierda at rna.nl
Fri Sep 20 20:42:23 UTC 2019


> On 20 Sep 2019, at 18:29, Dr M J Carter <Martin.Carter at physics.ox.ac.uk> wrote:
> 
> On Fri, Sep 20, 2019 at 05:33:02PM +0200, Gerben Wierda wrote:
>>   I’m new to tcl, so maybe this is simple, but I haven’t been able to solve
>>   it.
>> 
>> startupitem.start      "[variant_isset "withdnsserver"] ? "port load dns-server\n\t" : "" ] port load clamav-server
>> \tport load apache-solr8
>> \tport load redis
>> \tport load dcc
>> \tport load postfix
>> \tport load dovecot2
>> \tport load rspamd
>> \tport load logrotate"
>> 
>> 
>>   Now, obviously, this doesn’t work because of all the double quotes inside
>>   double quotes. 
>>   How do I do this without using variables?
> 
> Backslash-quote them, thus: "foo \"bar\" baz" -> foo "bar" baz
> 
> Hope this helps.

Actually, it doesn’t because the result is

        0 ? "port load dns-server
        " : "" ] port load clamav-server
        port load apache-solr8
        port load redis
        port load dcc

and not

        port load clamav-server
        port load apache-solr8
        port load redis
        port load dcc

What also doesn’t work is (with a variable):

set startupitemstring   [variant_isset "withdnsserver" ? "port load dns-server\n\t" : ""]
append startupitemstring "port load clamav-server
\tport load apache-solr8
\tport load redis
\tport load dcc
\tport load postfix
\tport load dovecot2
\tport load rspamd
\tport load logrotate"
startupitem.start       "$startupitemstring"

which gets me:

Error: Unable to open port: wrong # args: should be "variant_isset name"

And 

set startupitemstring   [variant_isset "withdnsserver"] ? "port load dns-server\n\t" : ""

gets me:

Error: Unable to open port: wrong # args: should be "set varName ?newValue?"

And

set startupitemstring	[[variant_isset "withdnsserver"] ? "port load dns-server\n\t" : ""]

gets me:

Error: Unable to open port: invalid command name "0"

Obviously, I do not understand tcl, but I also am unable to find any tcsl ternary operator example that uses strings like this.

Gerben Wierda
Chess and the Art of Enterprise Architecture <http://enterprisechess.com/>
Mastering ArchiMate <http://masteringarchimate.com/>
Architecture for Real Enterprises <https://www.infoworld.com/blog/architecture-for-real-enterprises/> at InfoWorld
On Slippery Ice <https://eapj.org/on-slippery-ice/> at EAPJ


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20190920/e18a2b57/attachment.html>


More information about the macports-users mailing list