myspaghetti / macos-virtualbox

Push-button installer of macOS Catalina, Mojave, and High Sierra guests in Virtualbox on x86 CPUs for Windows, Linux, and macOS
GNU General Public License v2.0
13.46k stars 1.11k forks source link

Shell history is mangled after running the script #642

Closed golimarrrr closed 1 year ago

golimarrrr commented 1 year ago

Possibly related to https://github.com/myspaghetti/macos-virtualbox/issues/638

After running the script, there are a lot of commands from macos-guest-virtualbox.sh inside the bash history. This makes sense, but they seem to include some control characters that break the Ctrl+R functionality (reverse-i-search) of bash, because if after using mycommand I do: CTRL+R mycommand it does not find any line, but grep mycommand ~/.bash_history does find it

Is there a way to run the script totally separately from the main shell that the user opens for other tasks?

myspaghetti commented 1 year ago

Yes, the script can be fully separated from the login shell, but that would require more code that finds where every executable is located. Relying on the login shell means that, in general, the script doesn't have to locate wget or unzip and so on. Complete separation would have the script looking in /bin, /usr/bin, /usr/local/bin and so on, and prompting the user for the location of an executables on failure to locate it.

The easiest way to exclude the script commands from zsh history is to run it explicitly with the shell command: zsh -i macos-guest-virtualbox.sh or non-interactively zsh macos-guest-virtualbox.sh

This would prevent the script commands from being added to the login shell's history. bash by default excludes the script commands from the login shell history.

golimarrrr commented 1 year ago

Ok, for bash I guess that running HISTFILE=/dev/null before running the script would work