#! /bin/sh

set -e

# A cut-down version of 'which' from debianutils.
searchpath () {
	PROGRAM="$1"
	IFS_SAVE="$IFS"
	IFS=:
	RET=1
	for ELEMENT in $PATH; do
		if [ -z "$ELEMENT" ]; then
			ELEMENT=.
		fi
		if [ -f "$ELEMENT/$PROGRAM" ] && \
		   [ -x "$ELEMENT/$PROGRAM" ]; then
			RET=0
			break
		fi
	done
	IFS="$IFS_SAVE"
	return "$RET"
}

if ([ "$1" = remove ] || [ "$1" = upgrade ]) && searchpath install-docs; then
	install-docs -r users-and-groups
fi

exit 0
