Skip to content
Snippets Groups Projects
Commit 2f823834 authored by Lawrence Wu's avatar Lawrence Wu Committed by Junegunn Choi
Browse files

[install] Don't touch dotfiles if not requested (#1048)

parent e1582b83
No related branches found
No related tags found
No related merge requests found
......@@ -305,20 +305,22 @@ append_line() {
line="$2"
file="$3"
pat="${4:-}"
lno=""
echo "Update $file:"
echo " - $line"
[ -f "$file" ] || touch "$file"
if [ $# -lt 4 ]; then
lno=$(\grep -nF "$line" "$file" | sed 's/:.*//' | tr '\n' ' ')
else
lno=$(\grep -nF "$pat" "$file" | sed 's/:.*//' | tr '\n' ' ')
if [ -f "$file" ]; then
if [ $# -lt 4 ]; then
lno=$(\grep -nF "$line" "$file" | sed 's/:.*//' | tr '\n' ' ')
else
lno=$(\grep -nF "$pat" "$file" | sed 's/:.*//' | tr '\n' ' ')
fi
fi
if [ -n "$lno" ]; then
echo " - Already exists: line #$lno"
else
if [ $update -eq 1 ]; then
echo >> "$file"
[ -f "$file" ] && echo >> "$file"
echo "$line" >> "$file"
echo " + Added"
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment