From 4d0f0b742694e677aac06c2d8ac44001562a218b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Wed, 24 Sep 2025 15:06:44 +0200 Subject: [PATCH] doc: refer to commands by name, not absolute path For simplicity and portability. I left some instances in README.OSX as is, because I'm worried about invalidating the docs. --- README | 6 +++--- man/faketime.1 | 10 +++++----- src/faketime.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README b/README index a7326ea..dce911f 100644 --- a/README +++ b/README @@ -256,10 +256,10 @@ the difference: LD_PRELOAD=src/libfaketime.so.1 FAKETIME="@2000-01-01 11:12:13" \ FAKETIME_DONT_RESET=1 \ - /bin/bash -c 'while [ $SECONDS -lt 5 ]; do date; sleep 1; done' + bash -c 'while [ $SECONDS -lt 5 ]; do date; sleep 1; done' LD_PRELOAD=src/libfaketime.so.1 FAKETIME="@2000-01-01 11:12:13" \ - /bin/bash -c 'while [ $SECONDS -lt 5 ]; do date; sleep 1; done' + bash -c 'while [ $SECONDS -lt 5 ]; do date; sleep 1; done' In the second example, the "date" command will always print the same time, while in the first example, with FAKETIME_DONT_RESET set, time will increment @@ -354,7 +354,7 @@ like "+0 x2", i.e., use an explicit zero offset as a prefix in your FAKETIME. For testing, your should run a command like LD_PRELOAD=./libfaketime.so.1 FAKETIME="+1,5y x10,0" \ -/bin/bash -c 'while true; do echo $SECONDS ; sleep 1 ; done' +bash -c 'while true; do echo $SECONDS ; sleep 1 ; done' For each second that the endless loop sleeps, the executed bash shell will think that 10 seconds have passed ($SECONDS is a bash-internal variable diff --git a/man/faketime.1 b/man/faketime.1 index aeb0d23..6b973f1 100644 --- a/man/faketime.1 +++ b/man/faketime.1 @@ -40,11 +40,11 @@ Use a specific GNU-date compatible implementation of the helper used to transfor .SH EXAMPLES .nf -faketime 'last Friday 5 pm' /bin/date -faketime '2008-12-24 08:15:42' /bin/date -faketime -f '+2,5y x10,0' /bin/bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done' -faketime -f '+2,5y x0,50' /bin/bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done' -faketime -f '+2,5y i2,0' /bin/bash -c 'while true; do date ; sleep 1 ; done' +faketime 'last Friday 5 pm' date +faketime '2008-12-24 08:15:42' date +faketime -f '+2,5y x10,0' bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done' +faketime -f '+2,5y x0,50' bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done' +faketime -f '+2,5y i2,0' bash -c 'while true; do date ; sleep 1 ; done' In this single case all spawned processes will use the same global clock without restarting it at the start of each process. (Please note that it depends on your locale settings whether . or , has to be used for fractional offsets) diff --git a/src/faketime.c b/src/faketime.c index ce7925b..cabbc49 100644 --- a/src/faketime.c +++ b/src/faketime.c @@ -84,11 +84,11 @@ void usage(const char *name) " --date-prog PROG : Use specified GNU-compatible implementation of 'date' program\n" "\n" "Examples:\n" - "%s 'last friday 5 pm' /bin/date\n" - "%s '2008-12-24 08:15:42' /bin/date\n" - "%s -f '+2,5y x10,0' /bin/bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done'\n" - "%s -f '+2,5y x0,50' /bin/bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done'\n" - "%s -f '+2,5y i2,0' /bin/bash -c 'date; while true; do date; sleep 1 ; done'\n" + "%s 'last friday 5 pm' date\n" + "%s '2008-12-24 08:15:42' date\n" + "%s -f '+2,5y x10,0' bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done'\n" + "%s -f '+2,5y x0,50' bash -c 'date; while true; do echo $SECONDS ; sleep 1 ; done'\n" + "%s -f '+2,5y i2,0' bash -c 'date; while true; do date; sleep 1 ; done'\n" "In this single case all spawned processes will use the same global clock\n" "without restarting it at the start of each process.\n\n" "(Please note that it depends on your locale settings whether . or , has to be used for fractions)\n"