waveterm/pkg/shparse/shparse_test.go
2022-11-14 19:57:29 -08:00

30 lines
642 B
Go

package shparse
import (
"fmt"
"testing"
)
// $(ls f[*]); ./x
// ls f => raw["ls f"] -> lit["ls f"] -> lit["ls"] lit["f"]
// w; ls foo; => raw["w; ls foo;"]
// ls&"ls" => raw["ls&ls"] => lit["ls&"] dq["ls"] => lit["ls"] key["&"] dq["ls"]
// ls $x; echo `ls f => raw["ls $x; echo `ls f"]
// > echo $foo{x,y}
func testParse(t *testing.T, s string) {
words := parseInput(s)
fmt.Printf("%s\n", s)
dumpWords(words)
fmt.Printf("\n")
}
func Test1(t *testing.T) {
testParse(t, "ls")
testParse(t, "ls 'foo'")
testParse(t, `ls "hello" $'\''`)
testParse(t, `ls "foo`)
testParse(t, `echo $11 $xyz $ `)
}