mirror of
https://github.com/Hilbis/Hilbish
synced 2025-03-29 09:43:22 +00:00
fix: get absolute path in fs.cd function
This commit is contained in:
parent
19feda919e
commit
ea233facc8
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user