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