Fix incorrect formatting of rbenv-help output under MAWK

In systems that use the MAWK interpreter (the default AWK installed with
Ubuntu), the output of `rbenv help <command>` would have no line breaks.
The issue is fixed by changing `gsub` to `sub` in the snippet of awk
commands that are used to extract documentation comments.

I suspect the bug is something to do with the way the '^' and '$'
characters are interpreted by different AWK interpreters (per-line vs
per-string anchors).

If I understand correctly, the purpose of trim() is to remove all line
breaks from the start and end of each sections of a command's
documentation, in which case `sub` should serve the same purpose.
This commit is contained in:
Leo Cassarani 2013-01-05 16:52:57 +00:00
parent bef7a12964
commit 1d687ac734

View file

@ -64,8 +64,8 @@ collect_documentation() {
}
function trim(str) {
gsub(/^\n*/, "", str)
gsub(/\n*$/, "", str)
sub(/^\n*/, "", str)
sub(/\n*$/, "", str)
return str
}