1 parent
7d21785af7
commit
784d80ca30
2 files changed
+31
-1
No files matched your search
@@ -71,6 +71,18 @@ var gEvalTests = []struct {
|
|||||||
[]expr{&callExpr{"echo", []string{"helloworld"}}},
|
[]expr{&callExpr{"echo", []string{"helloworld"}}},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
`echo "hello\0world"`,
|
||||||
|
[]string{"echo", "hello\000world", "\n"},
|
||||||
|
[]expr{&callExpr{"echo", []string{"hello\000world"}}},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
`echo "hello\101world"`,
|
||||||
|
[]string{"echo", "hello\101world", "\n"},
|
||||||
|
[]expr{&callExpr{"echo", []string{"hello\101world"}}},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
`echo hello\ world`,
|
`echo hello\ world`,
|
||||||
[]string{"echo", "hello world", "\n"},
|
[]string{"echo", "hello world", "\n"},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"strconv"
|
||||||
"unicode"
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,6 +85,10 @@ func isSpace(b byte) bool {
|
|||||||
return unicode.IsSpace(rune(b))
|
return unicode.IsSpace(rune(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isDigit(b byte) bool {
|
||||||
|
return unicode.IsDigit(rune(b))
|
||||||
|
}
|
||||||
|
|
||||||
func isPrefix(b byte) bool {
|
func isPrefix(b byte) bool {
|
||||||
// TODO: how to differentiate slash in path vs search?
|
// TODO: how to differentiate slash in path vs search?
|
||||||
return b == '$' || b == '!' || b == '&' // || b == '/' || b == '?'
|
return b == '$' || b == '!' || b == '&' // || b == '/' || b == '?'
|
||||||
@@ -228,7 +233,20 @@ scan:
|
|||||||
case 'v':
|
case 'v':
|
||||||
buf = append(buf, '\v')
|
buf = append(buf, '\v')
|
||||||
}
|
}
|
||||||
s.next()
|
if isDigit(s.chr) {
|
||||||
|
var oct []byte
|
||||||
|
for isDigit(s.chr) {
|
||||||
|
oct = append(oct, s.chr)
|
||||||
|
s.next()
|
||||||
|
}
|
||||||
|
n, err := strconv.ParseInt(string(oct), 8, 0)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("scanning: %s", err)
|
||||||
|
}
|
||||||
|
buf = append(buf, byte(n))
|
||||||
|
} else {
|
||||||
|
s.next()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
buf = append(buf, s.chr)
|
buf = append(buf, s.chr)
|
||||||
s.next()
|
s.next()
|
||||||
|
|||||||
Reference in new issue
Block a user