lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, 21 Aug 2008 18:27:57 -0300
"Hugo Schmitt" <hugows@gmail.com> top-posted:

> Or for that specific case
> 
> return os.getenv("PWD")

Which won't work if the process's working directory has chanced since
launch.

> require "posix"
> posix.chdir "Desktop"
> = os.getenv "PWD"
/home/rjek
> = io.popen("pwd", "r"):read "*a"
/home/rjek/Desktop

Of course, if you're using lposix, you'd just do this:

> = posix.getcwd()
/home/rjek/Desktop

But the current working directory could have been changed in any number
of ways.

B.