[MacPorts] #64326: app PortGroup: app.name unable to handle names with spaces
MacPorts
noreply at macports.org
Sun Jan 2 00:30:31 UTC 2022
#64326: app PortGroup: app.name unable to handle names with spaces
-------------------------+--------------------
Reporter: jasonliu-- | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.7.1
Resolution: | Keywords:
Port: pg-app-1.0 |
-------------------------+--------------------
Comment (by ryandesign):
Replying to [comment:2 jmroot]:
> There might be an issue in `_write_launch_script` due to `${executable}`
not being quoted.
No idea. Haven't looked at it. I wasn't involved in the "launch script"
improvements that were added to the portgroup.
Replying to [comment:3 jasonliu--]:
> Replying to [comment:1 ryandesign]:
> > Did you try:
> >
> > {{{
> > app.name AppName With Spaces
> > }}}
> >
> > Works fine in the chromium-bsu, frozenbubble2, and wesnoth ports, for
example.
>
> Ironically no, that was the one iteration I didn't try! And yes you're
right, it does work, although years of programming has been drilled into
me to never try to use a string naked like that, lol!
One of the main reasons why Tcl was chosen as the language to use for
MacPorts Portfiles is that it makes a bunch of extra quoting like that
unnecessary.
> Also, it would seem to preclude the use of names that have been stored
in a variables, since
>
> {{{
> set foo AppName With Spaces
> app.name $foo
> }}}
>
> throws a Tcl error of {{{wrong # args: should be "set varName
?newValue?"}}},
Correct; what you wrote is a syntax error. `set` accepts two arguments:
the name of the variable followed by the value.
MacPorts options (like `app.name`) are treated not as simple variables but
as lists that accept any number of arguments. However some options (like
`app.name`) for which a list of items doesn't make any sense instead treat
it as a single value. `app.name some long name` technically sets the
`app.name` option to a three item list ("some", "long", "name") but since
a list doesn't make sense in this context, the app portgroup concatenates
all the values into a single string separated by spaces.
> {{{
> set foo "AppName With Spaces"
> # or
> set foo {AppName With Spaces}
> }}}
Right, that's the correct way to set a variable to that string. What
quoting character you use — quote or curly brace — is irrelevant if you
don't have any variable substitutions within the string.
> {{{
> app.name $foo
> # or
> app.name "$foo"
> # or
> app.name {$foo}
> }}}
If you want to do it this way, you'll have to expand the variable:
{{{
app.name {*}$foo
}}}
It was not anticipated that anyone would have a need to use a separate
variable here. Why do you?
--
Ticket URL: <https://trac.macports.org/ticket/64326#comment:4>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list