mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-27 17:37:58 +01:00
25 lines
577 B
Go
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" $'\''`)
|
|
}
|