aboutsummaryrefslogtreecommitdiff
path: root/lib/os/exec/exec.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-08-12 23:39:53 +0700
committerShulhan <ms@kilabit.info>2021-08-13 13:32:57 +0700
commit1adcb7901dc62ef288cf82f504f8fae30068b21b (patch)
tree5248ac3f284c5102bff044e6e195bf9d4691be76 /lib/os/exec/exec.go
parent4aa4b560eb683d742dc7ff3136089c73f6a0023d (diff)
downloadpakakeh.go-1adcb7901dc62ef288cf82f504f8fae30068b21b.tar.xz
os/exec: include the quoted characters when ParseCommandArgs
Previously, if we pass `a "b c"` to ParseCommanArgs, it will return `a` as command and `b c` in args. Now, it will return `"b c"` in args with double quotes.
Diffstat (limited to 'lib/os/exec/exec.go')
-rw-r--r--lib/os/exec/exec.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/os/exec/exec.go b/lib/os/exec/exec.go
index 0fed245c..10391b8e 100644
--- a/lib/os/exec/exec.go
+++ b/lib/os/exec/exec.go
@@ -9,6 +9,7 @@
package exec
import (
+ "fmt"
"io"
"os"
"os/exec"
@@ -34,7 +35,8 @@ func ParseCommandArgs(in string) (cmd string, args []string) {
if r == quote {
arg := sb.String()
if len(arg) > 0 {
- cmdArgs = append(cmdArgs, sb.String())
+ arg = fmt.Sprintf("%c%s%c", quote, arg, quote)
+ cmdArgs = append(cmdArgs, arg)
}
sb.Reset()