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

[Bug]: Comments in bash are not logged #2537

Open
1 task done
TopherIsSwell opened this issue Jan 9, 2025 · 1 comment
Open
1 task done

[Bug]: Comments in bash are not logged #2537

TopherIsSwell opened this issue Jan 9, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@TopherIsSwell
Copy link

TopherIsSwell commented Jan 9, 2025

What did you expect to happen?

I expected this to function like bash history and record comments in the history.

Sometimes I begin writing a complex command and then realize I need more information before I can finish it, so I add a pound at the beginning of the command and press enter so its in my bash history. I collect the needed information, then I Ctrl-R to bring up the commented command and I remove the comment and finish the command.

Contrived example:

$ #for host in prod1e{1,2,3}-nginx-{1,2}; do rsync -avu "$host":/dev/ ...
$ ls /dev
$ for host in prod1e{1,2,3}-nginx-{1,2}; do rsync -avu "$host":/dev/cpuinfo "./$host-cpuinfo"; done

What happened?

Commands beginning with # are excluded from the history. However commands with a comment at the end of the line are included which is expected. They don't show up in Ctrl-R search. They do show up in bash's session history (I've disabled the keybinding in atuin, and when I press to navigate history, it's using bash and I see the commented commands).

$ echo comment #comment
comment

$ echo comment follows
comment follows

$ #My little comment

$ echo comment before this
comment before this

$ sqlite3 ~/.local/share/atuin/history.db 'select command from history order by timestamp desc limit 5;'
sqlite3 ~/.local/share/atuin/history.db 'select command from history order by timestamp desc limit 5;'
echo comment before this
echo comment follows
echo comment #comment
PS1="\$"

Requested fix

As a non-breaking fix, if there was a log_comments option in the config, then people who desire to have comments in their history would have the option without changing the default behavior for anyone who's come to expect/rely on comments being omitted.

Atuin doctor output

$ atuin doctor
Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues
{
  "atuin": {
    "version": "18.4.0",
    "sync": null,
    "sqlite_version": "3.46.0"
  },
  "shell": {
    "name": "bash",
    "default": "bash",
    "plugins": [
      "atuin",
      "bash-preexec"
    ],
    "preexec": "bash-preexec"
  },
  "system": {
    "os": "Fedora Linux",
    "arch": "x86_64",
    "version": "41",
    "disks": [
      {
        "name": "/dev/mapper/luks-9556d59c-31c9-42dd-b764-b55c36b97b0e",
        "filesystem": "xfs"
      },
      {
        "name": "/dev/vda3",
        "filesystem": "xfs"
      },
      {
        "name": "/dev/mapper/luks-fee58fff-f51d-4b58-8105-9e5167fbd205",
        "filesystem": "xfs"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project's Code of Conduct
@TopherIsSwell TopherIsSwell added the bug Something isn't working label Jan 9, 2025
@akinomyoga
Copy link
Contributor

As described in README, bash-preexec has a limitation. The behavior reported in this PR is actually the limitation. For details, ee [Bash]-[bash-preexec] on Installing the shell plugin - Atuin Docs. Check also the upstream issue rcaloras/bash-preexec#158.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants