diff --git a/ast/lex.go b/ast/lex.go index 6f672e5..d7db581 100644 --- a/ast/lex.go +++ b/ast/lex.go @@ -164,6 +164,15 @@ func lex(input string) *Token { case ';': i = matchLineEnd(i) start_pos = i + 1 + + // this isnt to handle string escaping + // its only to make sure that escaped spaces stay in + // the same token. + case '\\': + if i != len(input) - 1 && input[i+1] == ' '{ + // eat the backslash + input = input[:i] + input[i+1:] + } } if needs_alloc { diff --git a/util/shell_complete.go b/util/shell_complete.go index 86410d8..197b51b 100644 --- a/util/shell_complete.go +++ b/util/shell_complete.go @@ -80,7 +80,8 @@ func ShellCompleter(line string, vt ast.VarTable, ft ast.FuncTable) []string { completions := []string{} for _, i := range compSource { if strings.HasPrefix(i, tail) { - completions = append(completions, head + i) + str := strings.ReplaceAll(i, " ", "\\ ") + completions = append(completions, head + str) } }