From 0cdfbc76b51c23160879e8c31448b8aee8c40dd0 Mon Sep 17 00:00:00 2001 From: Philippe Godin Date: Thu, 15 Dec 2016 20:07:43 -0500 Subject: [PATCH] Refactored make help target Fixes issue #1450 --- scripts/help | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/scripts/help b/scripts/help index b4d558d8..6a132561 100755 --- a/scripts/help +++ b/scripts/help @@ -1,17 +1,23 @@ -#!/bin/bash -set -e +#!/bin/bash -e + +is_not_a_valid() { + local target=$1 + [ ! -x "$target" ] || [ ! -f "$target" ] +} + +get_help_statement_for() { + local target=$1 + grep '^# help:' $target | sed 's/# help://' +} cd $(dirname $0) +echo "Targets:" -echo Targets: - -for i in *; do - if [ ! -x $i ] || [ ! -f $i ]; then - continue - fi - - MSG=$(grep '^# help:' $i) - if [ -n "$MSG" ]; then - echo " " ${i}: $(echo $MSG | sed 's/# help://') - fi +for target in *; do + is_not_a_valid $target && continue + help_statement=$(get_help_statement_for $target) + if [ -n "$help_statement" ]; then + echo -e " $target: $help_statement" + fi done +