mirror of https://github.com/Hilbis/Hilbish
fix: errors and make login rc run before config
parent
38f1d62598
commit
7f8d8db53e
13
lua.go
13
lua.go
|
@ -17,7 +17,7 @@ prompt(ansikit.format(
|
||||||
))
|
))
|
||||||
`
|
`
|
||||||
|
|
||||||
func LuaInit(confpath string) {
|
func LuaInit() {
|
||||||
l = lua.NewState()
|
l = lua.NewState()
|
||||||
|
|
||||||
l.OpenLibs()
|
l.OpenLibs()
|
||||||
|
@ -66,12 +66,12 @@ func LuaInit(confpath string) {
|
||||||
"Missing preload file, builtins may be missing.")
|
"Missing preload file, builtins may be missing.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Run config
|
func RunConfig(confpath string) {
|
||||||
if !interactive {
|
if !interactive {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = l.DoFile(confpath)
|
err := l.DoFile(confpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err,
|
fmt.Fprintln(os.Stderr, err,
|
||||||
"\nAn error has occured while loading your config! Falling back to minimal default config.\n")
|
"\nAn error has occured while loading your config! Falling back to minimal default config.\n")
|
||||||
|
@ -84,7 +84,10 @@ func RunLogin() {
|
||||||
if _, err := os.Stat(homedir + "/.hprofile.lua"); os.IsNotExist(err) {
|
if _, err := os.Stat(homedir + "/.hprofile.lua"); os.IsNotExist(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = l.DoFile(homedir + "/.hprofile.lua")
|
if !login {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := l.DoFile(homedir + "/.hprofile.lua")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err,
|
fmt.Fprintln(os.Stderr, err,
|
||||||
"\nAn error has occured while loading your login config!n")
|
"\nAn error has occured while loading your login config!n")
|
||||||
|
|
5
main.go
5
main.go
|
@ -61,7 +61,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// first arg, first character
|
// first arg, first character
|
||||||
if loginshflag || os.Args[0][0] == "-" {
|
if loginshflag || os.Args[0][0] == '-' {
|
||||||
login = true
|
login = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
go HandleSignals()
|
go HandleSignals()
|
||||||
LuaInit(*configflag)
|
LuaInit()
|
||||||
RunLogin()
|
RunLogin()
|
||||||
|
RunConfig(*configflag)
|
||||||
|
|
||||||
readline.Completer = readline.FilenameCompleter
|
readline.Completer = readline.FilenameCompleter
|
||||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||||
|
|
Loading…
Reference in New Issue