Set env variable immediately in cli

Closes #151


Probably safer to check for `>= 0` just in case.