Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 460050 - readme.gentoo.eclass: Missing quotes around ${DOC_CONTENTS}
Summary: readme.gentoo.eclass: Missing quotes around ${DOC_CONTENTS}
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Pacho Ramos
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-02 22:31 UTC by Ulrich Müller
Modified: 2013-03-05 22:19 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2013-03-02 22:31:25 UTC
readme.gentoo_create_doc() currently does:
echo -e ${DOC_CONTENTS} | fmt > "${T}"/README.gentoo

According to fmt.info:

      `fmt' prefers breaking lines at the end of a sentence, and tries to
   avoid line breaks after the first word of a sentence or before the last
   word of a sentence.  A "sentence break" is defined as either the end of
   a paragraph or a word ending in any of `.?!', followed by two spaces or
   end of line, ignoring any intervening parentheses or quotes.

However, since there are no quotes around ${DOC_CONTENTS}, any two spaces or newline characters are changed into a single space, which means that fmt will not recognise any sentence endings. (In fact, it will never break a line after a full stop followed by a single space.)
Comment 1 Pacho Ramos gentoo-dev 2013-03-02 22:34:57 UTC
All this quoting is a hell for me :(

If I use "" fmt does nothing and exact content of DOC_CONTENTS is used, do you have any ideas for having DOC_CONTENTS content formatted by fmt even using quotes? :/
Comment 2 Ulrich Müller gentoo-dev 2013-03-02 22:57:23 UTC
The problem is that fmt doesn't join successive lines with different indentation. I believe that it would work if the indentation of each line is removed, like this:

  echo -e "${DOC_CONTENTS}" | sed 's/^[ \t]*//' | fmt > "${T}"/README.gentoo

But maybe it is overkill. A simple fold should also do the job (and doesn't care about sentence ends):

  echo -e ${DOC_CONTENTS} | fold -s -w 70 > "${T}"/README.gentoo
Comment 3 Pacho Ramos gentoo-dev 2013-03-02 23:01:59 UTC
Thanks, will try tomorrow, I am a bit tired (and also a bit angry due discussion on IRC :S)
Comment 4 Pacho Ramos gentoo-dev 2013-03-03 10:10:08 UTC
I am now building all packages using eclass to verify nothing breaks, only a question, what is preferred maximum line width? fmt was defaulting to 75, fold defaults to 80 but you force it to be 70

Thanks for the info
Comment 5 Ulrich Müller gentoo-dev 2013-03-03 11:53:01 UTC
According to readability studies, a line length around 70 characters is the optimum for human readable text. The exact value varies, for example the old netiquette guidelines say "limit line length to fewer than 65 characters": http://www.ietf.org/rfc/rfc1855.txt

Defaults of text editors for line wrapping are 70 chars for Emacs, and 72 chars for Vim and Nano. GLEP 42 (news items) also says 72.

So make it 70 or 72 please. 80 is definitely too long.
Comment 6 Pacho Ramos gentoo-dev 2013-03-03 12:05:10 UTC
+  03 Mar 2013; Pacho Ramos <pacho@gentoo.org> readme.gentoo.eclass:
+  Change formatting tool as discussed with Ulrich Müller in bug #460050,
+  thanks a lot to him for his help.
+
Comment 7 Ulrich Müller gentoo-dev 2013-03-05 18:33:19 UTC
Hm, I just see that fold outputs trailing whitespace. Would you mind if I add this:
   | sed "s/[[:space:]]*$//"
into the pipeline, after fold?
Comment 8 Pacho Ramos gentoo-dev 2013-03-05 22:19:23 UTC
(In reply to comment #7)
> Hm, I just see that fold outputs trailing whitespace. Would you mind if I
> add this:
>    | sed "s/[[:space:]]*$//"
> into the pipeline, after fold?

I have no problem... if you could rebuild packages inheritting readme.gentoo.eclass to check it doesn't break anything, would be better :)