From 4ee85f11e8b3474ae5ea4a292799f849c5fd9c02 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 18 Sep 2014 19:03:01 +0900 Subject: [PATCH] [install] Join line numbers when multiple matches found --- install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install b/install index 67fda00..bb81c27 100755 --- a/install +++ b/install @@ -338,15 +338,15 @@ append_line() { echo " - $1" [ -f "$2" ] || touch "$2" if [ $# -lt 3 ]; then - line=$(\grep -nF "$1" "$2" | sed 's/:.*//') + line=$(\grep -nF "$1" "$2" | sed 's/:.*//' | tr '\n' ' ') else - line=$(\grep -nF "$3" "$2" | sed 's/:.*//') + line=$(\grep -nF "$3" "$2" | sed 's/:.*//' | tr '\n' ' ') fi if [ -n "$line" ]; then - echo " - Already exists (line #$line)" + echo " - Already exists: line #$line" else echo "$1" >> "$2" - echo " - Added" + echo " + Added" fi echo }