Assume I have a git alias like this:
[alias]
abortalias = "! f() { \
read -p '> Press ctrl+c to cancel'; \
echo '> This should never be seen'; \
}; \
f"
And run git abortalias
, then press ctrl+c
when prompted. I'm expecting the script to cancel, instead what happens is that I pop out to the terminal, and my next input will trigger this error:
$ environment: line 0: read: read error: 0: Input/output error
> This should never be seen
This is also reproducible by adding a sleep 5
instead of the read -p
command and exiting during the sleep. The script will still resume.
Edit: Upon further testing, this only seems to happen inside a MINGW64 shell. Running from Powershell or CMD works just fine. Has to be some Windows quirk then I guess.
Edit 2: Specifically, it's git bash (MINGW64), ran through Visual Studio Code that's causing this issue. Running it in git bash (MINGW64) alone works, and running it in VSCode with another terminal works.
I've opened an issue in the VSCode repo meanwhile: https://github.com/microsoft/vscode/issues/149155