Windows installer script should be transactional
I tried the Windows Setup script at https://haskell.org/ghcup .
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -ArgumentList $true } catch { Write-Error $_ }
It asked me questions with the option to "Abort". I chose Abort after I already had answered "Reinstall" to GHCup. As a consequence, the original installation had been backed up from C:\ghcup to a temporary directory and there was a new C:\ghcup which was empty except for a bin subfolder.
So, you cannot really "Abort" in the middle. It is more like Hotel California:
You can check out at any time, but you can never leave.
I think such an installer should not interleave gathering information from the user and acting upon it.
Instead, it should prepare a transaction and then commit it. So, first gather the necessary information, then make a plan, and then execute the plan once it is clear that one can go through with it.
As it stands, a user having second thoughts and wanting to abort may end up in a broken state. Moreover, as it installs itself to global locations like C:\ghcup, it will be broken for all users on that machine.
The linux bootstrap script essentially works like that. PRs welcome.