[install] Join line numbers when multiple matches found

This commit is contained in:
Junegunn Choi 2014-09-18 19:03:01 +09:00
parent 829c7f909c
commit 4ee85f11e8

View File

@ -338,15 +338,15 @@ append_line() {
echo " - $1" echo " - $1"
[ -f "$2" ] || touch "$2" [ -f "$2" ] || touch "$2"
if [ $# -lt 3 ]; then if [ $# -lt 3 ]; then
line=$(\grep -nF "$1" "$2" | sed 's/:.*//') line=$(\grep -nF "$1" "$2" | sed 's/:.*//' | tr '\n' ' ')
else else
line=$(\grep -nF "$3" "$2" | sed 's/:.*//') line=$(\grep -nF "$3" "$2" | sed 's/:.*//' | tr '\n' ' ')
fi fi
if [ -n "$line" ]; then if [ -n "$line" ]; then
echo " - Already exists (line #$line)" echo " - Already exists: line #$line"
else else
echo "$1" >> "$2" echo "$1" >> "$2"
echo " - Added" echo " + Added"
fi fi
echo echo
} }