waveterm/pkg/shparse/shparse_test.go
2022-11-14 13:56:28 -08:00

25 lines
577 B
Go

package shparse
import (
"testing"
)
// $(ls f[*]); ./x
// ls f => raw["ls f"] -> lit["ls f"] -> lit["ls"] lit["f"]p
// 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) {
c := &parseContext{Input: []rune(s)}
words := c.parseQuotes()
c.dumpWords(words)
}
func Test1(t *testing.T) {
testParse(t, "ls")
testParse(t, "ls 'foo'")
testParse(t, `ls "hello" $'\''`)
}