~smlavine/dots

94e4ba76f4194276ecdd2015b57f3b7f0b52cee0 — Sebastian LaVine 20 days ago 05db57c
Properly install and uninstall files with spaces in their names

This bug was discovered because of a directory called 'dir has spaces'
in the vim-go submodule.
1 files changed, 4 insertions(+), 4 deletions(-)

M Makefile
M Makefile => Makefile +4 -4
@@ 7,7 7,7 @@ install:
	# awk is used to prepend $HOME instead of sed to avoid sed's delimiter
	# collision.
	find src -mindepth 1 -type d | sed 's/^src//' | \
		awk -v home="$(HOME)" '{ print home $$0 }' | \
		awk -v home="$(HOME)" '{ print "\"" home $$0 "\"" }' | \
		xargs mkdir -pv
	# Next, copy all files to their locations in $HOME.
	# 'sed p' repeats each line. The awk command prepends $HOME to make a


@@ 16,7 16,7 @@ install:
	find src -mindepth 1 -type f | sed p | \
		awk -v home="$(HOME)" \
		'NR%2==1 { print "cp -v -T " $$0 } \
		NR%2==0 { sub("^src",""); print home $$0 }' | \
		NR%2==0 { sub("^src",""); print "\"" home $$0 "\"" }' | \
		paste -d' ' - - | sh

uninstall:


@@ 24,11 24,11 @@ uninstall:
	# only want to remove empty directories, for safety's sake.
	find src -mindepth 1 -type f | \
		awk -v home="$(HOME)" \
		'{ sub("^src",""); print "rm -v " home $$0 }' | sh
		'{ sub("^src",""); print "rm -v " "\"" home $$0 "\"" }' | sh
	# Child directories echo first (-depth) so that parent directories are
	# emptied before removed.
	find src -mindepth 2 -type d -depth | sed 's/^src//' | \
		awk -v home="$(HOME)" '{ print home $$0 }' | \
		awk -v home="$(HOME)" '{ print "\"" home $$0 "\"" }' | \
		xargs rmdir -v

.PHONY: all install uninstall