func Argv(s string) []string {
	var ret []string
	var token []byte
	var context quote
	lastWhiteSpace := true
	for i := range []byte(s) {
		quotes := context != unquoted
		switch context {
		case unquoted:
			switch s[i] {
			case '\\':
				context = escape
				continue
			case '\'':
				context = singleQuote
				continue
			case '"':
				context = doubleQuote
				continue
			case '#':
				if lastWhiteSpace {
					context = comment
					continue
				}
			}
		case escape:
			context = unquoted
		case singleQuote:
			if s[i] == '\'' {
				context = unquoted
				continue
			}
		case doubleQuote:
			switch s[i] {
			case '\\':
				context = doubleQuoteEscape
				continue
			case '"':
				context = unquoted
				continue
			}
		case doubleQuoteEscape:
			switch s[i] {
			case '$', '"', '\\', '\n':  
			default:
				token = append(token, '\\')
			}
			context = doubleQuote
		case comment:
			continue
		}
		lastWhiteSpace = isWhitespace(s[i])
		if !isWhitespace(s[i]) || quotes {
			token = append(token, s[i])
		} else if len(token) > 0 {
			ret = append(ret, string(token))
			token = token[:0]
		}
	}
	if len(token) > 0 {
		ret = append(ret, string(token))
	}
	return ret
}
Argv splits a command line according to usual simple shell rules.

Argv was written from the spec of Grub quoting at
https://www.gnu.org/software/grub/manual/grub/grub.html#Quoting
except that the escaping of newline is not supported
package shlex
func isWhitespace(b byte) bool {
	return b == '\t' || b == '\n' || b == '\v' ||
		b == '\f' || b == '\r' || b == ' '
}
type quote uint8
const (
	unquoted quote = iota
	escape
	singleQuote
	doubleQuote
	doubleQuoteEscape
	comment
)