Skip to content

Commit

Permalink
Merge fa799d3 into 19c863e
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed Jun 10, 2021
2 parents 19c863e + fa799d3 commit 662afeb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ see [CONTRIBUTING.md](CONTRIBUTING.md#release-instructions-for-a-new-version) fo
## 1.10.x unreleased
- fix: `stringx.strip` behaved badly with string lengths > 200
[#382](https://github.com/lunarmodules/Penlight/pull/382)
- fix: `path.currentdir` now takes no arguments and calls `lfs.currentdir` without argument
[#383](https://github.com/lunarmodules/Penlight/pull/383)


## 1.10.0 (2021-04-27)
Expand Down
17 changes: 11 additions & 6 deletions lua/pl/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ local link_attrib = lfs.symlinkattributes
local path = {}

local function err_func(name, param, err, code)
if code == nil then
return ("%s failed for '%s': %s"):format(tostring(name), tostring(param), tostring(err))
local ret = ("%s failed"):format(tostring(name))
if param ~= nil then
ret = ret .. (" for '%s'"):format(tostring(param))
end
return ("%s failed for '%s': %s (code %s)"):format(tostring(name), tostring(param), tostring(err), tostring(code))
ret = ret .. (": %s"):format(tostring(err))
if code ~= nil then
ret = ret .. (" (code %s)"):format(tostring(code))
end
return ret
end

--- Lua iterator over the entries of a given directory.
Expand Down Expand Up @@ -80,10 +85,10 @@ end
--- Get the working directory.
-- Implicit link to [`luafilesystem.currentdir`](https://keplerproject.github.io/luafilesystem/manual.html#reference)
-- @function currentdir
path.currentdir = function(d)
local ok, err, code = currentdir(d)
path.currentdir = function()
local ok, err, code = currentdir()
if not ok then
return ok, err_func("currentdir", d, err, code), code
return ok, err_func("currentdir", nil, err, code), code
end
return ok, err, code
end
Expand Down

0 comments on commit 662afeb

Please sign in to comment.