Compare commits

..

No commits in common. "1eed4cc7ee70deb3eda5026db43007d00fe61929" and "20870b9004b9cad0441db069c8c11897b7f65686" have entirely different histories.

5 changed files with 16 additions and 22 deletions

View File

@ -27,9 +27,6 @@ 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
View File

@ -101,7 +101,7 @@ func runInput(input string, priv bool) {
cmdFinish(0, input, priv)
return
}
input, exitCode, cont, err = handleSh(cmdString)
input, exitCode, cont, err = handleSh(input)
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(cmdString)
input, exitCode, cont, err = handleSh(input)
}
} else {
// can only be a string or function so
@ -152,7 +152,6 @@ func reprompt(input string) (string, error) {
for {
in, err := continuePrompt(strings.TrimSuffix(input, "\\"))
if err != nil {
lr.SetPrompt(fmtPrompt(prompt))
return input, err
}
@ -221,17 +220,7 @@ func handleLua(cmdString string) (string, uint8, error) {
return cmdString, 125, err
}
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) {
func handleSh(cmdString string) (string, uint8, bool, error) {
_, _, err := execCommand(cmdString, true)
if err != nil {
// If input is incomplete, start multiline prompting

View File

@ -1,8 +1,13 @@
local fs = require 'fs'
local oldShRunner = hilbish.runner.sh
function hilbish.runner.sh(input)
local res = oldShRunner(input)
function cdHandle(inp)
local res = hilbish.runner.lua(inp)
if not res.err then
return res
end
res = hilbish.runner.sh(inp)
if res.exit ~= 0 and hilbish.opts.autocd then
local ok, stat = pcall(fs.stat, res.input)
@ -16,3 +21,5 @@ function hilbish.runner.sh(input)
return res
end
hilbish.runner.setMode(cdHandle)

View File

@ -4,6 +4,7 @@ import (
"fmt"
ansi "github.com/acarl005/stripansi"
"github.com/rivo/uniseg"
)
// SetPrompt will define the readline prompt string.
@ -208,7 +209,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 getWidth([]rune(stripped))
return uniseg.GraphemeClusterCount(stripped)
}
func (rl *Instance) echoRightPrompt() {

View File

@ -28,7 +28,7 @@ func shRunner(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return nil, err
}
input, exitCode, cont, err := execSh(cmd)
input, exitCode, cont, err := handleSh(cmd)
var luaErr rt.Value = rt.NilValue
if err != nil {
luaErr = rt.StringValue(err.Error())