Implement status command in a more portable way

See discussion on e6a427bed8f1d1db41804532e3071bc5d870ffc7