mirror of https://github.com/Hilbis/Hilbish
Compare commits
3 Commits
70a9e471eb
...
941902f43b
Author | SHA1 | Date |
---|---|---|
sammy | 941902f43b | |
sammy | cdd9dc1544 | |
sammy | e6382d454d |
13
main.go
13
main.go
|
@ -35,6 +35,7 @@ var (
|
|||
hooks bait.Bait
|
||||
interactive bool
|
||||
login bool // Are we the login shell?
|
||||
noexecute bool // Should we run Lua or only report syntax errors
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -47,14 +48,14 @@ func main() {
|
|||
setshflag := getopt.BoolLong("setshellenv", 'S', "Sets $SHELL to Hilbish's executed path")
|
||||
cmdflag := getopt.StringLong("command", 'c', "", /*TODO: Help description*/ "")
|
||||
configflag := getopt.StringLong("config", 'C', defaultconfpath, "Sets the path to Hilbish's config")
|
||||
// loginshflag
|
||||
// TODO: issue #37
|
||||
_ = getopt.BoolLong("login", 'l', "Makes Hilbish act like a login shell")
|
||||
_ = getopt.BoolLong("interactive", 'i', "Force Hilbish to be an interactive shell")
|
||||
getopt.BoolLong("login", 'l', "Makes Hilbish act like a login shell")
|
||||
getopt.BoolLong("interactive", 'i', "Force Hilbish to be an interactive shell")
|
||||
getopt.BoolLong("noexec", 'n', "Force Hilbish to be an interactive shell")
|
||||
|
||||
getopt.Parse()
|
||||
loginshflag := getopt.Lookup('l').Seen()
|
||||
interactiveflag := getopt.Lookup('i').Seen()
|
||||
noexecflag := getopt.Lookup('n').Seen()
|
||||
|
||||
if *cmdflag == "" || interactiveflag {
|
||||
interactive = true
|
||||
|
@ -64,6 +65,10 @@ func main() {
|
|||
interactive = false
|
||||
}
|
||||
|
||||
if noexecflag {
|
||||
noexecute = true
|
||||
}
|
||||
|
||||
// first arg, first character
|
||||
if loginshflag || os.Args[0][0] == '-' {
|
||||
login = true
|
||||
|
|
14
shell.go
14
shell.go
|
@ -16,9 +16,17 @@ import (
|
|||
)
|
||||
|
||||
func RunInput(input string) {
|
||||
// First try to run user input in Lua
|
||||
err := l.DoString(input)
|
||||
|
||||
// First try to load input, essentially compiling to bytecode
|
||||
fn, err := l.LoadString(input)
|
||||
if err != nil && noexecute {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
// And if there's no syntax errors and -n isnt provided, run
|
||||
if !noexecute {
|
||||
l.Push(fn)
|
||||
err = l.PCall(0, lua.MultRet, nil)
|
||||
}
|
||||
if err == nil {
|
||||
// If it succeeds, add to history and prompt again
|
||||
HandleHistory(input)
|
||||
|
|
Loading…
Reference in New Issue