f07e8ada33
Apply the same treatment to this script as the one in v4.18-278-g295cf32. * copyright-year-gen <year>: Change format to format:%cD, remove --date, supply output as a -d option argument to date +%Y.
28 lines
464 B
Bash
Executable File
28 lines
464 B
Bash
Executable File
#! /bin/sh
|
|
|
|
: ${YEAR_FILE:=$1}
|
|
: ${DEFAULT_YEAR:=$2}
|
|
|
|
year=
|
|
|
|
[ -n "${YEAR_FILE}" ] || {
|
|
echo >&2 "$0 $(dirname "$0")/.year [DEFAULT_YEAR]"
|
|
exit 1
|
|
}
|
|
|
|
[ -f "${YEAR_FILE}" ] && year="$(cat "${YEAR_FILE}")"
|
|
|
|
[ -n "${year}" ] ||
|
|
year="$(date +%Y -d "$(git show --format=format:%cD --no-patch)")"
|
|
|
|
[ -n "${year}" ] || year="${DEFAULT_YEAR}"
|
|
|
|
[ -n "${year}" ] || year="$(date "+%Y")"
|
|
|
|
[ -n "${year}" ] || {
|
|
echo >&2 'Undefined year.'
|
|
exit 1
|
|
}
|
|
|
|
printf "%s" "${year}"
|