$SECONDS variable becomes negative after 10 seconds
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.
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.
Any update? Not really an issue for me, just I am VERY curious why it happens. And why it's 10 seconds. 😅
Sorry, not yet. It is only known to affect bash so far (i.e., it does not seem to be a generic problem), and I didn't take the time to look into the bash implementation details yet. Maybe someone more familiar with the inner workings of bash could assist? :-)