wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.62k stars 319 forks source link

$SECONDS variable becomes negative after 10 seconds #470

Open mrechte opened 1 month ago

mrechte commented 1 month ago

This code will never end, because $SECONDS becomes negative after 10 seconds:

LD_PRELOAD=src/libfaketime.so.1 FAKETIME="@2000-01-01 11:12:13" \
  FAKETIME_DONT_RESET=1 \
  /bin/bash -c 'while [ $SECONDS -lt 20 ]; do date; echo $SECONDS; sleep 1; done'

Compiled and run on ArchLinux.

wolfcw commented 1 month ago

Nice one, thanks for reporting. :-)

Reproduces with bash on other platforms, but for example with zsh it works as expected. With bash, also other variables such as $EPOCHSECONDS are affected after ~10 seconds. Not sure where that comes from yet.