Skip to content

Commit

Permalink
fix: get absolute path in fs.cd function
Browse files Browse the repository at this point in the history
  • Loading branch information
TorchedSammy committed Jul 27, 2024
1 parent 19feda9 commit ea233fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion golibs/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ func (f *fs) fcd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
}
path = util.ExpandHome(strings.TrimSpace(path))

abspath, _ := filepath.Abs(path)
err = os.Chdir(path)
if err != nil {
return nil, err
}
interp.Dir(path)(f.runner)
interp.Dir(abspath)(f.runner)

return c.Next(), err
}
Expand Down
2 changes: 1 addition & 1 deletion nature/commands/cd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ commander.register('cd', function (args, sinks)
dirs.setOld(hilbish.cwd())
dirs.push(path)

local ok, err = pcall(function() fs.cd(fs.abs(path)) end)
local ok, err = pcall(function() fs.cd(path) end)
if not ok then
sinks.out:writeln(err)
return 1
Expand Down

0 comments on commit ea233fa

Please sign in to comment.