From 3a38a1a146f7b8c919cf638616eb9fa2064b34fc Mon Sep 17 00:00:00 2001 From: BaoXuebin Date: Mon, 19 Aug 2024 22:56:41 +0800 Subject: [PATCH] fix: exec.Command cannot output --- script/bql.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/bql.go b/script/bql.go index 17b6815..2573990 100644 --- a/script/bql.go +++ b/script/bql.go @@ -5,6 +5,7 @@ import ( "fmt" "os/exec" "reflect" + "regexp" "strconv" "strings" @@ -119,7 +120,9 @@ func BeanReportAllPrices(ledgerConfig *Config) []CommodityPrice { command = fmt.Sprintf(`bean-query %s "SELECT date, 'price', currency, price FROM account ~ 'Assets' WHERE price is not NULL"`, beanFilePath) } LogInfo(ledgerConfig.Mail, command) - cmd := exec.Command(command) + re := regexp.MustCompile(`"([^"]*)"|(\S+)`) + cmds := re.FindAllString(command, -1) + cmd := exec.Command(cmds[0], cmds[1:]...) output, _ := cmd.Output() outputStr := string(output) lines := strings.Split(outputStr, "\n")