Maybe my brain cells are slow today but even after reading a bunch of times I can't understand what's the point of the returns_ helper function. Could someone kindly give an explanation for dummies?
It checks for specific return code. It is useful for testing specific type of failure . Since in shell all non zero return codes are considered failure, we need a way to know that it failed because of the expected reason and not some other bug. So if testing for failure with err code 2, the function will "pass" the test only if the process actually fails with err code 2.