#SHELL=/bin/bash

go:
	./this-pylint --which-2 None --to-pylint mtee
	ps auxww | python3 ./mtee --serial 'head -1' 'egrep "\<1\>"'
	python3 ./mtee 'head > rm-me' 'cat > /dev/null' < /etc/services
	head /etc/services > expected
	diff expected rm-me
	python3 ./mtee 'head > rm-me' 'cat > /dev/null' < /etc/services
	diff expected rm-me
	python3 ./mtee 'cat > /dev/null' 'cat > rm-me' < /bin/sh
	cmp /bin/sh rm-me
	python3 ./mtee 'cat > /dev/null' 'cat > rm-me' < /bin/sh
	cmp /bin/sh rm-me
	find . -name .svn -prune -o -type f -print0 | tar --null --files-from - --create --file - | python3 mtee 'gzip > /dev/null' 'bzip2 > /dev/null' 'xz > foo.tar.xz'
	[ "$$(tar tvf foo.tar.xz 2>&1 | wc -l)" -gt 5 ]
	(echo 'echo 1'; echo 'echo 2') > /tmp/commands; cat /etc/passwd | ./mtee -f /tmp/commands 'grep root'
	(echo 'echo 1'; echo 'echo 2') > /tmp/commands; cat /etc/passwd | ./mtee --serial -f /tmp/commands 'grep root'
	if mtee 'exit 0' 'exit 1' 'exit 2' < /dev/null; then exit 1; else [ "$$?" = 2 ]; fi
	@echo All tests passed.

clean:
	rm -f rm-me expected foo.tar.xz *.pyc
	rm -rf __pycache__

install:
	./install-file --file mtee --directory /usr/local/bin