Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 586042 - repoman incorrectly warns about unquoted variables inside multiline quotes
Summary: repoman incorrectly warns about unquoted variables inside multiline quotes
Status: RESOLVED WONTFIX
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Repoman (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: EBUILD, PATCH
Depends on:
Blocks:
 
Reported: 2016-06-15 17:40 UTC by Coacher
Modified: 2022-07-12 03:18 UTC (History)
2 users (show)

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


Attachments
minorsyn-quoting-multiline-0.ebuild (minorsyn-quoting-multiline-0.ebuild,497 bytes, text/plain)
2016-06-15 17:41 UTC, Coacher
Details
0001-ebuild-test-add-test-for-variables-inside-multiline-.patch (0001-ebuild-test-add-test-for-variables-inside-multiline-.patch,2.59 KB, patch)
2016-06-15 17:42 UTC, Coacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Coacher 2016-06-15 17:40:54 UTC
Hello.

Example ebuild and patch for gen-b0rk attached.
repoman is 9999 @ 6c1264e.

Please fix.
Comment 1 Coacher 2016-06-15 17:41:40 UTC
Created attachment 437674 [details]
minorsyn-quoting-multiline-0.ebuild
Comment 2 Coacher 2016-06-15 17:42:26 UTC
Created attachment 437676 [details, diff]
0001-ebuild-test-add-test-for-variables-inside-multiline-.patch
Comment 3 Coacher 2016-06-15 17:45:43 UTC
Current repoman report:
RepoMan scours the neighborhood...
  ebuild.minorsyn               3
   ebuild-test/minorsyn-quoting-multiline/minorsyn-quoting-multiline-0.ebuild: Unquoted Variable on line: 16
   ebuild-test/minorsyn-quoting-multiline/minorsyn-quoting-multiline-0.ebuild: Unquoted Variable on line: 17
   ebuild-test/minorsyn-quoting-multiline/minorsyn-quoting-multiline-0.ebuild: Unquoted Variable on line: 18

Expected repoman report:
"If everyone were like you, I'd be out of business!"
Comment 4 Mike Gilbert gentoo-dev 2016-06-15 18:00:50 UTC
So how would you propose such variables be quoted? As long this string isn't passed to some command that cares about paths, it really doesn't matter.

Your example just shows a message that will be printed for the user; there's no need to print quotes in such a massage.
Comment 5 Mike Gilbert gentoo-dev 2016-06-15 18:03:46 UTC
Sorry, I misread your report. Please disregard my previous comment.
Comment 6 Zac Medico gentoo-dev 2016-06-15 19:18:46 UTC
This is a common complaint. However I argue that the warning is correct, on the grounds that the message refers to variables that can contain whitespace but fails to quote those variables.

Note that repoman will not warn if the variables are quoted as follows:

MESSAGE="
	${CATEGORY}/${PN}-${PVR} doesn't install files to '${EPREFIX}/',
	doesn't use temporary directory '${T}', or build directory '${S}',
	there are no patches in '${FILESDIR}' too.
"
Comment 7 Zac Medico gentoo-dev 2016-06-15 19:23:49 UTC
Also, note that changing be behavior of this quoting check might render the check useless, so we might as well remove the quoting check.
Comment 8 Coacher 2016-06-15 20:06:03 UTC
(In reply to Zac Medico from comment #6)
> This is a common complaint. However I argue that the warning is correct, on
> the grounds that the message refers to variables that can contain whitespace
> but fails to quote those variables.
The whole right side of ${MESSAGE} variable assignment is inside double quotes.
Where did I fail to quote a variable?

> Note that repoman will not warn if the variables are quoted as follows:
> 
> MESSAGE="
> 	${CATEGORY}/${PN}-${PVR} doesn't install files to '${EPREFIX}/',
> 	doesn't use temporary directory '${T}', or build directory '${S}',
> 	there are no patches in '${FILESDIR}' too.
> "
Sorry, but this has different contents: new quotes are added, which I don't want/need.
Comment 9 Zac Medico gentoo-dev 2016-06-15 20:53:17 UTC
(In reply to Coacher from comment #8)
> (In reply to Zac Medico from comment #6)
> > This is a common complaint. However I argue that the warning is correct, on
> > the grounds that the message refers to variables that can contain whitespace
> > but fails to quote those variables.
> The whole right side of ${MESSAGE} variable assignment is inside double
> quotes.
> Where did I fail to quote a variable?

The QA check in question is more properly defined as a "whitespace leakage" check than a quote check. It checks for cases where variables that might contain whitespace are not quoted in a way that separates whitespace inside the variables from the surrounding whitespace. For example "install files to ${EPREFIX}/," does not have quotes separating whitespace in the ${EPREFIX} variable from the whitespace the immediately precedes it (the space after the word "to").


> > Note that repoman will not warn if the variables are quoted as follows:
> > 
> > MESSAGE="
> > 	${CATEGORY}/${PN}-${PVR} doesn't install files to '${EPREFIX}/',
> > 	doesn't use temporary directory '${T}', or build directory '${S}',
> > 	there are no patches in '${FILESDIR}' too.
> > "
> Sorry, but this has different contents: new quotes are added, which I don't
> want/need.

As explained above, the quotes that you don't want are needed to separate whitespace in the variable from surrounding whitespace.
Comment 10 Coacher 2016-06-15 21:10:27 UTC
(In reply to Zac Medico from comment #9)
> The QA check in question is more properly defined as a "whitespace leakage"
> check than a quote check. It checks for cases where variables that might
> contain whitespace are not quoted in a way that separates whitespace inside
> the variables from the surrounding whitespace. For example "install files to
> ${EPREFIX}/," does not have quotes separating whitespace in the ${EPREFIX}
> variable from the whitespace the immediately precedes it (the space after
> the word "to").
Thanks, I understand now. Then this check is inconsistent because according to it
```
MESSAGE="
Bla bla ${EPREFIX}/, ${T}, ${S}.
"
einfo ${MESSAGE}
```
is illegal, but
```
einfo "Bla bla ${EPREFIX}/, ${T}, ${S}."
```
is perfectly fine.
IMHO both of these should be right or wrong at the same time.
Comment 11 Zac Medico gentoo-dev 2016-06-15 22:12:51 UTC
(In reply to Coacher from comment #10)
> IMHO both of these should be right or wrong at the same time.

Sure, but I'm afraid it might trigger a backlash from ebuild developers. :)

The difference in behavior traces back to this commit:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=420a428b6e59afd5e5743c8ac9b19a281410e9f1
Comment 12 Coacher 2016-06-15 22:40:11 UTC
(In reply to Zac Medico from comment #11)
This commit filters out "matches that appear to be an argument to a message command". Why have you said before that quoting is required in my original example with a multiline ${MESSAGE} variable? I also just pass this variable to the einfo command. Applying the above 'filtering out' logic repoman shouldn't warn about those unquoted variables.

This is confusing. In the comments you say that quoting is required to separate variables from the surrounding whitespaces, but your commit allows to omit this quoting for messages, which is the most important (only?) place where these special variables with whitespaces need additional quotes (here I mean single quotes from your comment#6).
Comment 13 Coacher 2016-06-15 22:48:21 UTC
So

einfo "${S}"

is fine, but

einfo "
${S}
"

is not. This doesn't make sense.
Comment 14 Zac Medico gentoo-dev 2016-06-15 23:46:58 UTC
It only makes sense as a way to mitigate complains from ebuild developers.
Comment 15 Coacher 2016-06-16 00:11:15 UTC
The proper way is to add everywhere in messages extra quotes to separate variables from the surrounding whitespaces like this:

einfo "'${EPREFIX}' this is easy to distinguish".

And repoman allows things like this:

einfo "${EPREFIX} this is hard to distinguish"

just to avoid an avalanche of complaints.

Right?
Comment 16 Zac Medico gentoo-dev 2016-06-16 00:13:54 UTC
Correct.
Comment 17 Coacher 2016-06-16 00:29:40 UTC
(In reply to Zac Medico from comment #16)
> Correct.
Got it. Thank you very much for the explanation.
Comment 18 Coacher 2016-06-16 00:37:03 UTC
Check is still broken for multiline variables though. :)

No warning:
	einfo "foo ${S} bar"

Warning:
	einfo "foo
	${S}
	bar"

No warning:
	MESSAGE="foo ${S} bar"; einfo ${MESSAGE}

Warning:
	MESSAGE="foo
	${S}
	bar"; einfo ${MESSAGE}
Comment 19 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-12 03:18:15 UTC
repoman support has been removed per bug 835013.

Please file a new bug (or, I suppose, reopen this one) if you feel this check is still applicable to pkgcheck and doesn't already exist.