lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.51k stars 1.47k forks source link

Lens causes local bash history to be truncated to 500 lines #7872

Open istepaniuk opened 1 year ago

istepaniuk commented 1 year ago

Describe the bug When opening a terminal, Lens executes bash with an --init-file parameter, which overrides the local and global .bashrc files.

This causes bash to use built-in defaults for $HISTSIZE and related variables (which is 500 lines). Consequently, bash truncates the .bash_history file to those 500 lines.

To Reproduce Steps to reproduce the behavior:

  1. Have your ~/.bashrc export $HISTSIZE to a large value, e.g. 1000.
  2. Run several commands in an interactive bash shell so you fill your history file.
  3. Verify that $HISTCMD is ~1000
  4. Open Lens and launch a local terminal within Lens, then close it.
  5. Launch a new interactive bash shell and verify the problem: $HISTCMD is now 500. Half of your history is gone!

Expected behavior Lens should not override the bash initialization file, the history should be preserved.

Environment

Jeansen commented 1 year ago

I cannot reproduce this. Lens 6.5.2 on Debian (Unstable). Did you build Lens yourself?

istepaniuk commented 1 year ago

Did you build Lens yourself?

Yes. I can also reproduce on OpenLens 6.5.2.309.

This line of code adds --init-file, I can see Lens runs /bin/bash --init-file .bash_set_path and the bash man page states:

--init-file --rcfile Execute commands from file instead of the system wide initialization file /etc/bash.bashrc and the standard personal initialization file ~/.bashrc if the shell is interactive.

Do you perhaps have HISTSIZE and HISTFILESIZE also set elsewhere, even for non-interactive shells?

Jeansen commented 1 year ago

Hm..interesting. I build Lens myself with jenkins within a docker container. Container is: electronuserland/builder:16 And then I build it with npm run build:app

@istepaniuk If you want, I can provide my build in a google drive for you to test.