mirror of
https://github.com/skywind3000/z.lua
synced 2026-03-15 04:09:49 +00:00
fixed: issue on calculating absolute path name of a symbol link
This commit is contained in:
19
z.lua
19
z.lua
@@ -309,13 +309,28 @@ function os.path.abspath(path)
|
||||
else
|
||||
local test = os.path.which('realpath')
|
||||
if test ~= nil and test ~= '' then
|
||||
return os.call('realpath \'' .. path .. '\'')
|
||||
test = os.call('realpath -s \'' .. path .. '\' 2> /dev/null')
|
||||
if test ~= nil and test ~= '' then
|
||||
return test
|
||||
end
|
||||
end
|
||||
if os.path.isdir(path) then
|
||||
if os.path.exists('/bin/sh') and os.path.exists('/bin/pwd') then
|
||||
local cmd = "/bin/sh -c 'cd \"" ..path .."\"; /bin/pwd'"
|
||||
test = os.call(cmd)
|
||||
if test ~= nil and test ~= '' then
|
||||
return test
|
||||
end
|
||||
end
|
||||
end
|
||||
local test = os.path.which('perl')
|
||||
if test ~= nil and test ~= '' then
|
||||
local s = 'perl -MCwd -e "print Cwd::realpath(\\$ARGV[0])" \'%s\''
|
||||
local s = string.format(s, path)
|
||||
return os.call(s)
|
||||
test = os.call(s)
|
||||
if test ~= nil and test ~= '' then
|
||||
return test
|
||||
end
|
||||
end
|
||||
for _, python in pairs({'python', 'python2', 'python3'}) do
|
||||
local s = 'sys.stdout.write(os.path.abspath(sys.argv[1]))'
|
||||
|
||||
Reference in New Issue
Block a user