File: datefudge.sh

package info (click to toggle)
datefudge 1.12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 60 kB
  • ctags: 16
  • sloc: makefile: 76; ansic: 58; sh: 22
file content (33 lines) | stat: -rwxr-xr-x 774 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

# Fake the system time

dat="$1"

if [ "$dat" = "-v" -o "$dat" = "--version" ] ; then
	echo "$0: Version @VERSION@"
	echo ""
	echo "For usage information, use '$0 --help'."
	exit 0
fi
if [ -z "$dat" -o "$dat" = "-h" -o "$dat" = "-?" -o "$dat" = "--help" ] ; then
	echo "Usage: $0 date program args..."
	echo ""
	echo "Run 'program' with 'args'."
	echo "The program will believe that the current time is 'date'."
	if [ -z "$dat" ] ; then exit 1; else exit 0; fi
fi

shift

# Assume that 'date' already printed an error message
sec=$(date -d "$dat" '+%s')
if [ $? -ne 0 ] ; then exit 1 ; fi

sec=$(expr $(date '+%s') - $sec)
if [ $? -ne 0 ] ; then exit 1 ; fi

export LD_PRELOAD="${LD_PRELOAD}${LD_PRELOAD:+:}/usr/lib/datefudge.so"
export DATEFUDGE=$sec

exec "$@"