Skip to content

Commit dcaea2b

Browse files
authored
Fix --quote with spaces (knqyf263#177)
1 parent 5d0345a commit dcaea2b

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

Diff for: cmd/exec.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/fatih/color"
99
"github.com/knqyf263/pet/config"
1010
"github.com/spf13/cobra"
11+
"gopkg.in/alessio/shellescape.v1"
1112
)
1213

1314
// execCmd represents the exec command
@@ -23,7 +24,7 @@ func execute(cmd *cobra.Command, args []string) (err error) {
2324

2425
var options []string
2526
if flag.Query != "" {
26-
options = append(options, fmt.Sprintf("--query %s", flag.Query))
27+
options = append(options, fmt.Sprintf("--query %s", shellescape.Quote(flag.Query)))
2728
}
2829

2930
commands, err := filter(options)

Diff for: cmd/search.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/knqyf263/pet/config"
88
"github.com/spf13/cobra"
99
"golang.org/x/crypto/ssh/terminal"
10+
"gopkg.in/alessio/shellescape.v1"
1011
)
1112

1213
var delimiter string
@@ -24,7 +25,7 @@ func search(cmd *cobra.Command, args []string) (err error) {
2425

2526
var options []string
2627
if flag.Query != "" {
27-
options = append(options, fmt.Sprintf("--query %s", flag.Query))
28+
options = append(options, fmt.Sprintf("--query %s", shellescape.Quote(flag.Query)))
2829
}
2930
commands, err := filter(options)
3031
if err != nil {

Diff for: go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ require (
2323
golang.org/x/oauth2 v0.0.0-20180603041954-1e0a3fa8ba9a
2424
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
2525
google.golang.org/appengine v1.0.0 // indirect
26+
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 // indirect
2627
)

Diff for: go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193
4444
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
4545
google.golang.org/appengine v1.0.0 h1:dN4LljjBKVChsv0XCSI+zbyzdqrkEwX5LQFUMRSGqOc=
4646
google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
47+
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 h1:8ajkpB4hXVftY5ko905id+dOnmorcS2CHNxxHLLDcFM=
48+
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61/go.mod h1:IfMagxm39Ys4ybJrDb7W3Ob8RwxftP0Yy+or/NVz1O8=

0 commit comments

Comments
 (0)