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