#!/bin/sh -e
#
# add-to-gitignore - auto_maintain: add_to_gitignore

error_handler() {
  >&2 echo "Exited with '${2}' in ${0} script at line: ${1}."
  exit "$2"
}
trap 'error_handler ${LINENO} $?' INT HUP
set -e

thing_to_add="$1"
echo "adding ${thing_to_add} to .gitignore"
# shellcheck disable=SC2312
if [ -n "$(tail -c 1 .gitignore)" ]; then
  thing_to_add="
${thing_to_add}"
fi
echo "${thing_to_add}" >>.gitignore
