summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorLawrence Wu <5601392+llwu@users.noreply.github.com>2017-09-10 17:18:26 -0700
committerJunegunn Choi <junegunn.c@gmail.com>2017-09-11 09:18:26 +0900
commit2f8238342b9b2388e4cf235a3de4e717890db0bb (patch)
tree97fa49b550dd049b01feeab0f083927f937de110 /install
parente1582b8323a70785d7ebefce993df7474a28e749 (diff)
[install] Don't touch dotfiles if not requested (#1048)
Diffstat (limited to 'install')
-rwxr-xr-xinstall14
1 files changed, 8 insertions, 6 deletions
diff --git a/install b/install
index 416ec896..c6b4b8c0 100755
--- a/install
+++ b/install
@@ -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