From 1d687ac734a42cf179d41fb850705f8db9932c3c Mon Sep 17 00:00:00 2001 From: Leo Cassarani Date: Sat, 5 Jan 2013 16:52:57 +0000 Subject: [PATCH] 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 ` 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. --- libexec/rbenv-help | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/rbenv-help b/libexec/rbenv-help index 6dd6fd6e..f15e83fd 100755 --- a/libexec/rbenv-help +++ b/libexec/rbenv-help @@ -64,8 +64,8 @@ collect_documentation() { } function trim(str) { - gsub(/^\n*/, "", str) - gsub(/\n*$/, "", str) + sub(/^\n*/, "", str) + sub(/\n*$/, "", str) return str }