b = (X^TX)^-1 X^T y

But i came across some matlab code which claims to solve by OLS but actually just solves it as a system of linear equations:

b = X^-1 y

Are these really the same thing? Doesn't OLS assume that there is some variance in y while the other just solves the system in a deterministic manner?

I've read on wikipedia that the matrix (X^TX)^-1 X^T, is also referred to as the Moore-Penrose pseudo-inverse so are they comparable depending on the rank of the X?

p.s. anyone else having trouble with latex at the moment?