Compare commits

..

No commits in common. "fd478e883f4dd8ee905f8dabb116e55488cfad7c" and "8f94990fc3ebb1d5fe91978a1f40b7cfb94c0c18" have entirely different histories.

4 changed files with 14 additions and 23 deletions

4
lua.go
View File

@ -65,9 +65,9 @@ func LuaInit() {
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?.lua'
`)
err := l.DoFile("preload.lua")
err := l.DoFile("/usr/share/hilbish/preload.lua")
if err != nil {
err = l.DoFile("/usr/share/hilbish/preload.lua")
err = l.DoFile("preload.lua")
if err != nil {
fmt.Fprintln(os.Stderr,
"Missing preload file, builtins may be missing.")

18
main.go
View File

@ -14,11 +14,10 @@ import (
"github.com/pborman/getopt"
"github.com/bobappleyard/readline"
"github.com/yuin/gopher-lua"
"layeh.com/gopher-luar"
"golang.org/x/term"
)
const version = "0.4.1-dev.7"
const version = "0.4.0"
var (
l *lua.LState
@ -47,7 +46,7 @@ func main() {
// parser := argparse.NewParser("hilbish", "A shell for lua and flower lovers")
verflag := getopt.BoolLong("version", 'v', "Prints Hilbish version")
setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path")
cmdflag := getopt.StringLong("command", 'c', "", "Executes a command on startup")
cmdflag := getopt.StringLong("command", 'c', "", /*TODO: Help description*/ "")
configflag := getopt.StringLong("config", 'C', defaultconfpath, "Sets the path to Hilbish's config")
getopt.BoolLong("login", 'l', "Makes Hilbish act like a login shell")
getopt.BoolLong("interactive", 'i', "Force Hilbish to be an interactive shell")
@ -109,17 +108,13 @@ func main() {
}
}
go HandleSignals()
LuaInit()
RunLogin()
RunInput(*cmdflag)
RunConfig(*configflag)
readline.Completer = readline.FilenameCompleter
readline.LoadHistory(homedir + "/.hilbish-history")
RunInput(*cmdflag)
if getopt.NArgs() > 0 {
l.SetGlobal("args", luar.New(l, getopt.Args()))
err := l.DoFile(getopt.Arg(0))
if err != nil {
fmt.Fprintln(os.Stderr, err)
@ -128,6 +123,11 @@ func main() {
os.Exit(0)
}
readline.Completer = readline.FilenameCompleter
readline.LoadHistory(homedir + "/.hilbish-history")
go HandleSignals()
for interactive {
running = false

View File

@ -20,8 +20,8 @@ commander.register('cd', function (args)
if err == 1 then
print('directory does not exist')
end
return err
end
bait.throw('command.exit', err)
else bait.throw('command.exit', 0) end
return
end
fs.cd(os.getenv 'HOME')

View File

@ -52,17 +52,9 @@ func RunInput(input string) {
l.GetGlobal("commanding"),
lua.LString("__commands")),
cmdArgs[0]),
NRet: 1,
NRet: 0,
Protect: true,
}, luar.New(l, cmdArgs[1:]))
luaexitcode := l.Get(-1)
exitcode := lua.LNumber(0)
l.Pop(1)
if code, ok := luaexitcode.(lua.LNumber); luaexitcode != lua.LNil && ok {
exitcode = code
}
if err != nil {
fmt.Fprintln(os.Stderr,
"Error in command:\n\n" + err.Error())
@ -70,7 +62,6 @@ func RunInput(input string) {
if cmdArgs[0] != "exit" {
HandleHistory(cmdString)
}
hooks.Em.Emit("command.exit", exitcode)
return
}