Hi Simon, 

Hmm I'm not sure about replacing sh with bash. I think bash has some Non-POSIX extensions that may affect the behavior of valid posix scripts. 

Is bash --login slow as well? How about once sh or bash starts, are commands still slow then? 

I assume your computer is domain joined and you may be hitting a very long standing issue with certain domain joined machines https://github.com/Alexpux/MSYS2-packages/issues/138#issuecomment-70813762

The solution seems to be to cache the user info locally instead of it having to query the domain controller everytime. See solution 2 here 
https://gist.github.com/k-takata/9b8d143f0f3fef5abdab for instructions 

Does that help the problem? 

I believe you had a similar problem last time setting up a new machine. At that time magit was also slow. 

Kind regards, 
Tamar 

On Mon, Apr 2, 2018, 23:23 Simon Peyton Jones <simonpj@microsoft.com> wrote:

Tamar

I’ve noticed that “sh” (which is invoked at lot by make etc) takes AGES to start up.  At least I think it’s ‘sh’ that is causing the delay.

I think it’s c:/msys64/usr/bin/sh.exe

From searching the web (eg https://www2.cs.duke.edu/csl/docs/unix_course/intro-60.html)  it seems likely that it executes c:/msys64/etc/profile first.

And If I put an ‘echo’ at the start and end of that file, they do seem to take place with a significant gap between them.

I have not started sprinkling more echos, but does that ring any bells?

Can I replace ‘sh’ with c:/msys64/usr/bin/bash.exe, which seems to be faster?   (My evnt variable SHELL already points to bash.exe. )  And if so, how would I do that? An environment variable.  Physically copy bash.exe to sh.exe?  Or what?

Thanks

Simon