2
3
镜像自地址 https://github.com/sammy-ette/Hilbish 已同步 2025-08-10 02:52:03 +00:00

fix: get absolute path in fs.cd function

这个提交包含在:
sammyette 2024-07-27 14:28:09 -04:00
父节点 19feda919e
当前提交 ea233facc8
签署人:: sammyette
GPG 密钥 ID: 904FC49417B44DCD
共有 2 个文件被更改,包括 3 次插入2 次删除

查看文件

@ -110,11 +110,12 @@ func (f *fs) fcd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
} }
path = util.ExpandHome(strings.TrimSpace(path)) path = util.ExpandHome(strings.TrimSpace(path))
abspath, _ := filepath.Abs(path)
err = os.Chdir(path) err = os.Chdir(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }
interp.Dir(path)(f.runner) interp.Dir(abspath)(f.runner)
return c.Next(), err return c.Next(), err
} }

查看文件

@ -19,7 +19,7 @@ commander.register('cd', function (args, sinks)
dirs.setOld(hilbish.cwd()) dirs.setOld(hilbish.cwd())
dirs.push(path) 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 if not ok then
sinks.out:writeln(err) sinks.out:writeln(err)
return 1 return 1