#!/bin/bash -e

test -z $1 && echo "Error: Missing target dependency path parameter" && exit 1
test -z $2 && echo "Error: Missing target dependency type parameter" && exit 2

_path=$1
_type=$2

shift; shift

test -z $1 && echo "Error: Missing target dependency parameter" && exit 3

test ! -d $_path && mkdir -p $_path

NAME=$_type-$(basename $0)
if test -f $_path/$NAME
then
  grep "$@" $_path/$NAME &> /dev/null || echo "$@" >> $_path/$NAME
else
  echo "$@" > $_path/$NAME
fi
