mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
Don't crash the compiler when redirection sign is invalid.
This fixes #484.
This commit is contained in:
parent
3f73d8474b
commit
01d611aabd
|
@ -378,6 +378,10 @@ func (cp *compiler) redir(n *parse.Redir) OpFunc {
|
|||
sourceIsFd := n.RightIsFd
|
||||
mode := n.Mode
|
||||
flag := makeFlag(mode)
|
||||
if flag == -1 {
|
||||
// TODO: Record and get redirection sign position
|
||||
cp.errorf("bad redirection sign")
|
||||
}
|
||||
|
||||
return func(ec *EvalCtx) {
|
||||
var dst int
|
||||
|
|
|
@ -88,8 +88,7 @@ func makeFlag(m parse.RedirMode) int {
|
|||
case parse.Append:
|
||||
return os.O_WRONLY | os.O_CREATE | os.O_APPEND
|
||||
default:
|
||||
// XXX should report parser bug
|
||||
panic("bad RedirMode; parser bug")
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user