mirror of https://github.com/Hilbis/Hilbish
Compare commits
6 Commits
20870b9004
...
1eed4cc7ee
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 1eed4cc7ee | |
TorchedSammy | c13889592f | |
TorchedSammy | 2e192be2e1 | |
TorchedSammy | c96605e79c | |
TorchedSammy | a1ce2ecba6 | |
TorchedSammy | a1410ae7ad |
|
@ -27,6 +27,9 @@ func splitQuote(str string) []string {
|
|||
sb.WriteRune(r)
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(str, " ") {
|
||||
split = append(split, "")
|
||||
}
|
||||
|
||||
if sb.Len() > 0 {
|
||||
split = append(split, sb.String())
|
||||
|
|
17
exec.go
17
exec.go
|
@ -101,7 +101,7 @@ func runInput(input string, priv bool) {
|
|||
cmdFinish(0, input, priv)
|
||||
return
|
||||
}
|
||||
input, exitCode, cont, err = handleSh(input)
|
||||
input, exitCode, cont, err = handleSh(cmdString)
|
||||
case "hybridRev":
|
||||
_, _, _, err = handleSh(input)
|
||||
if err == nil {
|
||||
|
@ -112,7 +112,7 @@ func runInput(input string, priv bool) {
|
|||
case "lua":
|
||||
input, exitCode, err = handleLua(cmdString)
|
||||
case "sh":
|
||||
input, exitCode, cont, err = handleSh(input)
|
||||
input, exitCode, cont, err = handleSh(cmdString)
|
||||
}
|
||||
} else {
|
||||
// can only be a string or function so
|
||||
|
@ -152,6 +152,7 @@ func reprompt(input string) (string, error) {
|
|||
for {
|
||||
in, err := continuePrompt(strings.TrimSuffix(input, "\\"))
|
||||
if err != nil {
|
||||
lr.SetPrompt(fmtPrompt(prompt))
|
||||
return input, err
|
||||
}
|
||||
|
||||
|
@ -220,7 +221,17 @@ func handleLua(cmdString string) (string, uint8, error) {
|
|||
return cmdString, 125, err
|
||||
}
|
||||
|
||||
func handleSh(cmdString string) (string, uint8, bool, error) {
|
||||
func handleSh(cmdString string) (input string, exitCode uint8, cont bool, runErr error) {
|
||||
shRunner := hshMod.Get(rt.StringValue("runner")).AsTable().Get(rt.StringValue("sh"))
|
||||
var err error
|
||||
input, exitCode, cont, runErr, err = runLuaRunner(shRunner, cmdString)
|
||||
if err != nil {
|
||||
runErr = err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func execSh(cmdString string) (string, uint8, bool, error) {
|
||||
_, _, err := execCommand(cmdString, true)
|
||||
if err != nil {
|
||||
// If input is incomplete, start multiline prompting
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
local fs = require 'fs'
|
||||
|
||||
function cdHandle(inp)
|
||||
local res = hilbish.runner.lua(inp)
|
||||
|
||||
if not res.err then
|
||||
return res
|
||||
end
|
||||
|
||||
res = hilbish.runner.sh(inp)
|
||||
local oldShRunner = hilbish.runner.sh
|
||||
function hilbish.runner.sh(input)
|
||||
local res = oldShRunner(input)
|
||||
|
||||
if res.exit ~= 0 and hilbish.opts.autocd then
|
||||
local ok, stat = pcall(fs.stat, res.input)
|
||||
|
@ -21,5 +16,3 @@ function cdHandle(inp)
|
|||
|
||||
return res
|
||||
end
|
||||
|
||||
hilbish.runner.setMode(cdHandle)
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
|
||||
ansi "github.com/acarl005/stripansi"
|
||||
"github.com/rivo/uniseg"
|
||||
)
|
||||
|
||||
// SetPrompt will define the readline prompt string.
|
||||
|
@ -209,7 +208,7 @@ func (rl *Instance) colorizeVimPrompt(p []rune) (cp []rune) {
|
|||
// getting its real-printed length.
|
||||
func getRealLength(s string) (l int) {
|
||||
stripped := ansi.Strip(s)
|
||||
return uniseg.GraphemeClusterCount(stripped)
|
||||
return getWidth([]rune(stripped))
|
||||
}
|
||||
|
||||
func (rl *Instance) echoRightPrompt() {
|
||||
|
|
|
@ -28,7 +28,7 @@ func shRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
input, exitCode, cont, err := handleSh(cmd)
|
||||
input, exitCode, cont, err := execSh(cmd)
|
||||
var luaErr rt.Value = rt.NilValue
|
||||
if err != nil {
|
||||
luaErr = rt.StringValue(err.Error())
|
||||
|
|
Loading…
Reference in New Issue