Compare commits

..

3 Commits

Author SHA1 Message Date
sammyette 805eefcd17
fix: use hilbish.home instead of home env var 2021-06-14 18:12:12 -04:00
sammyette eab3f27ebf
fix: throw cd hook only after changing directory 2021-06-14 18:11:07 -04:00
sammyette 30ffe9cab0
fix: handle error before getting commander exit code
this fixes a register underflow issue if a commander causes an error
2021-06-14 18:02:44 -04:00
2 changed files with 9 additions and 6 deletions

View File

@ -10,7 +10,6 @@ if shlvl ~= nil then os.setenv('SHLVL', shlvl + 1) else os.setenv('SHLVL', 1) en
-- Builtins
commander.register('cd', function (args)
bait.throw('cd', args)
if #args > 0 then
local path = ''
for i = 1, #args do
@ -32,9 +31,11 @@ commander.register('cd', function (args)
end
return err
end
bait.throw('cd', path)
return
end
fs.cd(os.getenv 'HOME')
fs.cd(hilbish.home)
bait.throw('cd', hilbish.home)
return
end)

View File

@ -56,6 +56,12 @@ func RunInput(input string) {
NRet: 1,
Protect: true,
}, luar.New(l, cmdArgs[1:]))
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
hooks.Em.Emit("command.exit", 1)
return
}
luaexitcode := l.Get(-1)
var exitcode uint8 = 0
@ -65,10 +71,6 @@ func RunInput(input string) {
exitcode = uint8(code)
}
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
}
hooks.Em.Emit("command.exit", exitcode)
return
}