From ea233facc87c61e55bca60f5dc6885f6307cc179 Mon Sep 17 00:00:00 2001 From: sammyette Date: Sat, 27 Jul 2024 14:28:09 -0400 Subject: [PATCH] fix: get absolute path in fs.cd function --- golibs/fs/fs.go | 3 ++- nature/commands/cd.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/golibs/fs/fs.go b/golibs/fs/fs.go index 13f972d..002be90 100644 --- a/golibs/fs/fs.go +++ b/golibs/fs/fs.go @@ -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 } diff --git a/nature/commands/cd.lua b/nature/commands/cd.lua index 22078d9..7cfe4a2 100644 --- a/nature/commands/cd.lua +++ b/nature/commands/cd.lua @@ -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