[PATCH 14/25] env: Split out non-command code into a new file