Compartmentalize dir checking of argv to immediately close dirs

Part of #1
Explicitly close dir fds

Closes #1
go fmt