Permalink
Browse files

improved user feedback: show matched string using 'grep --color'

Signed-off-by: Tj Holowaychuk <tj@vision-media.ca>
  • Loading branch information...
1 parent 89e2047 commit e28c359a7ae43ecc325fb65be3c8f3ee023f7b05 @jweslley jweslley committed with tj Nov 10, 2010
Showing with 7 additions and 5 deletions.
  1. +6 −4 bin/git-ignore
  2. +1 −1 etc/gitignore
View
@@ -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

0 comments on commit e28c359

Please sign in to comment.