rbenv help: fix 'type: write error: Broken pipe'

Sometimes the command fails with a 'type: write error: Broken pipe'.
This is because 'head -1' only reads the first line, then exits.
If 'type' writes the second line after 'head -1' has already exited,
then the aforementioned error is triggered.

We fix this by buffering the entire output of 'type' before
invoking 'head -1'.
This commit is contained in:
Hongli Lai 2019-10-23 08:19:16 +02:00
parent 577f04653d
commit d38d18ec25
No known key found for this signature in database
GPG key ID: D68B88EE474ABDBB

View file

@ -42,8 +42,13 @@ extract_initial_comment_block() {
}
collect_documentation() {
local all_awks
local first_awk
all_awks=$(type -p gawk awk)
first_awk=$(head -1 <<<"$all_awks")
# shellcheck disable=SC2016
$(type -p gawk awk | head -1) '
"$first_awk" '
/^Summary:/ {
summary = substr($0, 10)
next