Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 281834 - The dash character should not be allowed in a variable name in make.defaults
Summary: The dash character should not be allowed in a variable name in make.defaults
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: PMS/EAPI
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-17 19:31 UTC by Jacob Godserv
Modified: 2009-09-02 19:02 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Quick fix for the ambiguous wording (0001-Add-a-word-so-list-of-allowed-variable-name-characte.patch,1.03 KB, patch)
2009-08-26 20:58 UTC, Christian Faulhammer (RETIRED)
Details | Diff
Updated patch without dash in character list (0001-Add-a-word-so-list-of-allowed-variable-name-characte.patch,1.10 KB, patch)
2009-08-31 13:42 UTC, Christian Faulhammer (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jacob Godserv 2009-08-17 19:31:25 UTC
This ought to be assigned to pms-bugs@gentoo.org, I think.

This is a bug in the specification "HEAD", under section 5.2.4. It states:
"A variable name must start with one of a-zA-Z and may contain a-zA-Z0-9_-."

The following conversation occurred in #gentoo-portage:
15:24 < ABCD> of course, the spec is wrong in allowing "-" in a variable name
15:25 < javaJake> ABCD: but it's in the spec
15:25 < ABCD> javaJake: but the spec is wrong :)

Thus, this report. ;)
Comment 1 Christian Faulhammer (RETIRED) gentoo-dev 2009-08-26 09:34:03 UTC
And why is a dash not allowed?  Could you give me a pointer?
Comment 2 Jacob Godserv 2009-08-26 12:26:54 UTC
Because bash itself doesn't allow dash characters in variable names, and make.defaults is essentially a big bash script.
Comment 3 Ciaran McCreesh 2009-08-26 12:28:45 UTC
It's not a bash script.
Comment 4 Ulrich Müller gentoo-dev 2009-08-26 13:24:01 UTC
(In reply to comment #3)
> It's not a bash script.

But it's profile-like and you could source it from a shell. So IMHO it would be wise to restrict the allowed characters to the ones that POSIX allows <http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_230>:
"a word consisting solely of underscores, digits, and alphabetics from the portable character set. The first character of a name is not a digit."

(In reply to comment #0)
> [...] may contain a-zA-Z0-9_-."

The full stop should also be disallowed, by the way.
Comment 5 Ciaran McCreesh 2009-08-26 13:32:52 UTC
POSIX there is much more restrictive than Unix. It's perfectly legal to have an environment variable with a hyphen or a dot in the name. Is there any reason to believe that we won't, for example, introduce ABI values that have a hyphen in them in the future?

I ask because if the rules change, Paludis will enforce it and Portage likely won't, which in turn means as soon as people start relying upon something that PMS declares illegal, there will be the usual cries about PMS being a Paludis conspiracy and how PMS should be fixed...
Comment 6 Ulrich Müller gentoo-dev 2009-08-26 13:52:15 UTC
(In reply to comment #5)
> POSIX there is much more restrictive than Unix. It's perfectly legal to have
> an environment variable with a hyphen or a dot in the name.

Every character except = and NUL is legal in environment variables I think.

But valid identifiers in bash may not contain any hyphens. And PMS itself states that make.defaults uses "a small subset of bash syntax", so currently it's self-contradictory.

> Is there any reason to believe that we won't, for example, introduce ABI
> values that have a hyphen in them in the future?

This doesn't sound very useful to me, especially if the price to pay is the loss of shell compatibility.
Comment 7 Ciaran McCreesh 2009-08-26 13:57:23 UTC
Actually, dots are a better example... PYTHON_ABI=2.5, and then PYTHON_ABI_2.5_BLAH=something comes to mind.

*shrug* I'm not opposed to changing it, but if we do, it's probably wise to make sure Portage enforces it.
Comment 8 Ulrich Müller gentoo-dev 2009-08-26 18:04:19 UTC
(In reply to comment #7)
> Actually, dots are a better example... PYTHON_ABI=2.5, and then
> PYTHON_ABI_2.5_BLAH=something comes to mind.

Hm, but the _source_ of profiles.tex shows that the dot is already disallowed:

# A variable name must start with one of \t{a-zA-Z} and may contain
# \t{a-zA-Z0-9\_-}.

The full stop denotes end of sentence here. ;-) But it is very misleading, maybe the sentence should be rearranged to have at least one word after the charset.

> *shrug* I'm not opposed to changing it, but if we do, it's probably wise to
> make sure Portage enforces it.

Portage silently ignores variables with a dash in their name, and neither exports them to the ebuild environment nor saves them in the VDB. I think that's good enough.
Comment 9 Ciaran McCreesh 2009-08-26 18:09:41 UTC
(In reply to comment #8)
> The full stop denotes end of sentence here. ;-) But it is very misleading,
> maybe the sentence should be rearranged to have at least one word after the
> charset.

Yeah, I generally try to do that, but don't always remember. Perhaps someone could make a patch for all of the existing cases of that...

> Portage silently ignores variables with a dash in their name, and neither
> exports them to the ebuild environment nor saves them in the VDB. I think
> that's good enough.

Alright. Although I'd still prefer it if this could get updated to warning noisily. Silently skipping things scares me.
Comment 10 Christian Faulhammer (RETIRED) gentoo-dev 2009-08-26 20:58:07 UTC
Created attachment 202348 [details, diff]
Quick fix for the ambiguous wording

(In reply to comment #9)
> (In reply to comment #8)
> > The full stop denotes end of sentence here. ;-) But it is very misleading,
> > maybe the sentence should be rearranged to have at least one word after the
> > charset.
> 
> Yeah, I generally try to do that, but don't always remember. Perhaps someone
> could make a patch for all of the existing cases of that...

 The attached one fixes the wording, but still includes the dash in the last.  Do we want to remove it?

> > Portage silently ignores variables with a dash in their name, and neither
> > exports them to the ebuild environment nor saves them in the VDB. I think
> > that's good enough.
> 
> Alright. Although I'd still prefer it if this could get updated to warning
> noisily. Silently skipping things scares me.

 I told Zac via IM, he wants to fix that.
Comment 11 Jacob Godserv 2009-08-26 22:43:02 UTC
(In reply to comment #10)
>  The attached one fixes the wording, but still includes the dash in the last. 
> Do we want to remove it?

I would say yes. No one is opposed, and by removing the dash the PMS is more consistent and things work (like a bash script) the way people expect them to.

(The only argument against this change was "It's not a bash script." but the response "PMS itself states that make.defaults uses 'a small subset of bash syntax" and "valid identifiers in bash may not contain any hyphens" showed how it is really a very simple bash script.)
Comment 12 Zac Medico gentoo-dev 2009-08-28 09:45:24 UTC
(In reply to comment #10)
>  I told Zac via IM, he wants to fix that.

Fixed: http://sources.gentoo.org/viewcvs.py/portage?rev=14167&view=rev
Comment 13 Ulrich Müller gentoo-dev 2009-08-29 00:44:09 UTC
(In reply to comment #10)
>  The attached one fixes the wording, but still includes the dash in the last.
> Do we want to remove it?

Yes, definitely.
Comment 14 Christian Faulhammer (RETIRED) gentoo-dev 2009-08-31 13:42:30 UTC
Created attachment 202800 [details, diff]
Updated patch without dash in character list
Comment 15 Christian Faulhammer (RETIRED) gentoo-dev 2009-09-02 18:50:51 UTC
So no objections if I commit above change?
Comment 16 Ciaran McCreesh 2009-09-02 18:56:29 UTC
wfm
Comment 17 Christian Faulhammer (RETIRED) gentoo-dev 2009-09-02 19:02:14 UTC
Committed.