diff --git a/tokenslice.go b/tokenslice.go index 0e54857..7f0be64 100644 --- a/tokenslice.go +++ b/tokenslice.go @@ -1,6 +1,9 @@ package shlex -import "strconv" +import ( + "strconv" + "strings" +) type TokenSlice []Token @@ -103,9 +106,18 @@ func (t TokenSlice) WordbreakPrefix() string { found = true } + switch token.State { + case QUOTING_STATE, QUOTING_ESCAPING_STATE: + found = true + } + if found { prefix = token.Value + prefix } } + + if prefix == "" && len(t) > 0 { + prefix = "~" + } return prefix }