mirror of https://github.com/Hilbis/Hilbish
fix: expansion on quotes in alias expansion
to show what this fixes: `git commit -m "a commit message"` would report that it didnt find pathspecs for commit or message, because the commit message is only passed as `a` also fixes it to make it work in commands in other sh syntaxwindows-fixes
parent
9d685ab785
commit
5787582c2e
16
shell.go
16
shell.go
|
@ -9,6 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
|
"mvdan.cc/sh/v3/shell"
|
||||||
//"github.com/yuin/gopher-lua/parse"
|
//"github.com/yuin/gopher-lua/parse"
|
||||||
"mvdan.cc/sh/v3/interp"
|
"mvdan.cc/sh/v3/interp"
|
||||||
"mvdan.cc/sh/v3/syntax"
|
"mvdan.cc/sh/v3/syntax"
|
||||||
|
@ -85,10 +86,19 @@ func execCommand(cmd string) error {
|
||||||
|
|
||||||
exechandle := func(ctx context.Context, args []string) error {
|
exechandle := func(ctx context.Context, args []string) error {
|
||||||
_, argstring := splitInput(strings.Join(args, " "))
|
_, argstring := splitInput(strings.Join(args, " "))
|
||||||
|
// i dont really like this but it works
|
||||||
|
if aliases.All()[args[0]] != "" {
|
||||||
|
for i, arg := range args {
|
||||||
|
if strings.Contains(arg, " ") {
|
||||||
|
args[i] = fmt.Sprintf("\"%s\"", arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, argstring = splitInput(strings.Join(args, " "))
|
||||||
|
|
||||||
// If alias was found, use command alias
|
// If alias was found, use command alias
|
||||||
argstring = aliases.Resolve(argstring)
|
argstring = aliases.Resolve(argstring)
|
||||||
args, _ = splitInput(argstring)
|
args, _ = shell.Fields(argstring, nil)
|
||||||
|
}
|
||||||
|
|
||||||
// If command is defined in Lua then run it
|
// If command is defined in Lua then run it
|
||||||
luacmdArgs := l.NewTable()
|
luacmdArgs := l.NewTable()
|
||||||
|
|
Loading…
Reference in New Issue