Init error in devbox shell

Hi there,

I’m new to atuin and ran into an error when atuin tries to initialize in my devbox shell.

bash: 1725026352513710 - : syntax error: operand expected (error token is "- ")

I narrowed down, that the failing command in .bashrc is eval “$(atuin init bash)”.

I belief, the atuin init bash script that it tries to evaluate causes the error at this line:

elif [[ $- != i ]]; then
# Enable only in interactive shells
false

After every command it complains about this error and doesn’t add the command to the history. If I run something from the history, the problem is gone and atuin works like it should.

I do not understand, what exactly is going wrong, nor how to solve this. Can anybody help me with this issue?

Thanks, underdunk

Just a drive-by observation here; that error message suggests that there’s a subtraction evaluation happening, i.e. something - somethingelse and the somethingelse is missing. The something, here the value 1725026352513710, looks like a (longer version of a) Unix epoch timestamp. And the only place I can see in atuin.bash that does this sort of thing is in __atuin_precmd() here:

duration=$((${__atuin_precmd_time//[!0-9]} - ${__atuin_preexec_time//[!0-9]}))

which (confirmation bias aside) does seem to relate to timestamp subtractions.

So it could be in this area?

Thank you for your help.

For the moment I put a [[ ! ${__atuin_preexec_time} ]] && return as exit condition in the __atuin_precmd function.

What version of bash are you using here?

I use GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu), but inside of devbox it is GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu).

I’ve spent the last two days looking into this a little deeper than what was mentioned here. Here are a few things I have found:

  • entering a devbox shell specifically does not trigger the __atuin_preexec() function. Therefore, __atuin_preexec_time is never set, resulting in the error at the top of this thread.
  • Specifically setting an init_hook in devbox.json will fix the issue as long as there is output (to trigger __atuin_preexec), but this is not ideal.
  • atuin v17.2.1 does not have this issue since it was released shortly before changes to the duration were made. I do not have any issues running v17.2.1 with devbox.
  • I also noticed that it only errored when I typed devbox shell, not if I used the atuin history and selected the devbox shell command and ran it from there. Additionally, after running a couple commands in the devbox shell, the __atuin_preexec_time is set and the error goes away.

Although both @underdunk and I have ran into this issue while using devbox, I think the issue is more to do with the bash-preexec hook not being called when entering the shell.

Would it be enough in __atuin_precmd() to do something like:

__atuin_preexec_time=${__atuin_preexec_time:-__atuin_precmd_time}

which should result in a duration = 0 - which I think makes sense if the preexec hook does not fire?