2 # vim: set sw=4 expandtab:
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # Copyright (C) 2016 Jérôme Pouiller <jezz@sysmic.org>
22 if ! readlink
-f "$0" |
grep -q fakedate
; then
23 echo "fakedate: Please name this script \`fakedate'"
28 # Do not call `date' directly since it will produce an infinite recursion.
29 # Instead, find path of true `date' binary.
30 for P
in `echo $PATH | tr ':' ' '`; do
31 if [ -x "$P/date" ]; then
32 if readlink
-f "$P/date" |
grep -qv fakedate
; then
39 if [ -n "$SOURCE_DATE_EPOCH" ]; then
42 # Use of --date, --file and --reference (and their short option counter
43 # parts) is incompatible with SOURCE_DATE_EPOCH.
44 # -u and -R are the only short options without argument. So they could
45 # appear between '-' and option we want to match.
46 if echo "$i" |
grep -qE '^-([uR]*d|-date|[uR]*f|-file|[uR]*r|--reference)'; then
51 if [ $FORCE_EPOCH -eq 1 ]; then
52 echo "date: Warning: using \$SOURCE_DATE_EPOCH instead of true time" >&2
53 exec $DATE_BIN -d "@$SOURCE_DATE_EPOCH" "$@"