[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"
[ -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
}