General eshell get-or-create function and stealing some things from rubbish.