dir = os.getenv("PWD") or io.popen("cd"):read()
Tries to get a system environment variable PWD. If it is a linux system, it will contain working directory. Will ignore io.popen() then due to short-circuit evaluation.
If enviroment variable PWD doesn't exists, it executes cmd command "cd" and reads the result, which will work on windows systems.
If enviroment variable PWD doesn't exists, it executes cmd command "cd" and reads the result, which will work on windows systems.