Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$SECONDS variable becomes negative after 10 seconds #470

Open
mrechte opened this issue May 22, 2024 · 3 comments
Open

$SECONDS variable becomes negative after 10 seconds #470

mrechte opened this issue May 22, 2024 · 3 comments

Comments

@mrechte
Copy link

mrechte commented May 22, 2024

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
Copy link
Owner

wolfcw commented May 29, 2024

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.

@AgainPsychoX
Copy link

Any update? Not really an issue for me, just I am VERY curious why it happens. And why it's 10 seconds. 😅

@wolfcw
Copy link
Owner

wolfcw commented Aug 7, 2024

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? :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants