From 3ed8d50f5c52bd8424e707e99bfcc5785129b8a2 Mon Sep 17 00:00:00 2001 From: Jonhnny Weslley Date: Wed, 10 Nov 2010 14:52:18 -0300 Subject: [PATCH] improved user feedback: show matched string using 'grep --color' --- bin/git-ignore | 10 ++++++---- etc/gitignore | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/git-ignore b/bin/git-ignore index fbc159c..4c23546 100755 --- a/bin/git-ignore +++ b/bin/git-ignore @@ -9,12 +9,14 @@ done if [ ! -z "$template" ]; then gitignoredir="`dirname $0`/../etc/gitignore" - selected_template=$(find $gitignoredir -type f -name *.gitignore | xargs -i basename {} .gitignore | sort | grep $template) - count=$(echo $selected_template | wc -w) + selected_template() { + find $gitignoredir -type f -name *.gitignore | xargs -i basename {} .gitignore | sort | grep $template + } + count=$(selected_template | wc -w) case "$count" in 0) echo "The pattern '$template' does not match any available templates." && exit 1;; - 1) find $gitignoredir -name $selected_template.gitignore -exec cat {} \; >> .gitignore && echo "... added patterns from template '$selected_template'";; - *) echo "Be more specific. $count macthes found:\n$selected_template" && exit 2;; + 1) find $gitignoredir -name $(selected_template).gitignore -exec cat {} \; >> .gitignore && echo "... added patterns from template '$(selected_template)'";; + *) echo "Be more specific. $count macthes found:" && selected_template | grep --color $template && exit 2;; esac fi diff --git a/etc/gitignore b/etc/gitignore index 0a41318..acbcdb0 160000 --- a/etc/gitignore +++ b/etc/gitignore @@ -1 +1 @@ -Subproject commit 0a41318dba7094f7f97646280a0096e30b6cd596 +Subproject commit acbcdb02e5e608cfd1c9a93eba67c6a73d632870