go-shellwords icon indicating copy to clipboard operation
go-shellwords copied to clipboard

Suggestion: Allow Certain Operators to Be Parsed as Tokens

Open eugene-yzm opened this issue 2 years ago • 0 comments

Specifically, I was testing:

s := "pg_dump db -U usr -F c > bck.dump"
argv, _ := shellwords.Parse(s)
for _, v := range argv {
  println(v)
}

Which returned:

pg_dump
db
-U
usr
-F
c

I noticed in the source code (https://github.com/mattn/go-shellwords/blob/master/shellwords.go#L246) that we're not accepting ">" as a token amongst other characters like "|". Since these characters are very important in certain contexts, I think it might make sense to add a flag which will recognize them as tokens (by flag I mean something similar to p.ParseBacktick = true).

eugene-yzm avatar Jun 16 '23 22:06 eugene-yzm