msys2-pacman icon indicating copy to clipboard operation
msys2-pacman copied to clipboard

[UX] pacman -Syu core update discards bash history

Open Artoria2e5 opened this issue 1 year ago • 3 comments

Description / Steps to reproduce the issue

  1. Open a Window of MSYS2 MSYS
  2. Do anything to populate bash history
  3. Do pacman -Syu and make sure it's a core update
  4. Do the update
  5. Re-open the window

Expected behavior

I expect the history to be preserved, like with a normal close.

Actual behavior

The close is forced (for good reason) and no history is saved from the session.

Verification

  • [X] I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)

(but you need to wait until it's outdated to reproduce it! oh or just make a fake update tarball.)

Windows Version

MSYS_NT-10.0-22624

Are you willing to submit a PR?

Yes, if we figure out the best way. A possible way is putting this in the default bashrc, but I am not sure it's "graceful" enough (what if it's not a core update? that would change behavior!). It also needs to cover other shells and so on.

pacman() {
  history -a;
  command pacman "$@";
}

Or maybe we make kill_all_other_msys_processes() do a normal sigterm in the MSYS2 context before the taskkill????

Artoria2e5 avatar Apr 11 '23 09:04 Artoria2e5

Yeah, that's not ideal right now, thanks

lazka avatar Apr 15 '23 20:04 lazka

There are a few issues, open questions:

  • bash ignores SIGTERM, so that doesn't work
  • bash allows SIGHUP though (is that a good idea?)
  • Does killing bash kill pacman running in it as well? Otherwise we don't get a chance of sending SIGKILL.

We could special case the parent processes of pacman somehow maybe?

lazka avatar Apr 15 '23 20:04 lazka

Does killing bash kill pacman running in it as well

Ho, that's a good one! SIGHUP probably does that. I guess pacman can add a signal (SIGHUP, SIG_IGN); in the core upgrade bit?

Artoria2e5 avatar Apr 16 '23 04:04 Artoria2e5