From 659a1305dd42f666ffcbea3ac7d6a633fb9e0058 Mon Sep 17 00:00:00 2001 From: bashbunni <15822994+bashbunni@users.noreply.github.com> Date: Wed, 13 Apr 2022 09:24:05 -0700 Subject: [PATCH] fix: fix string literal parsing for delimiter (#30) * fix: fix string literal parsing for delimiter --- main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 6c7a833..90ceec9 100755 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "strings" "unicode/utf8" @@ -165,7 +166,11 @@ func list(cmd *cobra.Command, args []string) error { if keysIterate || valuesIterate { pf = "%s\n" } else { - pf = fmt.Sprintf("%%s%s%%s\n", delimiterIterate) + var err error + pf, err = strconv.Unquote(fmt.Sprintf(`"%%s%s%%s\n"`, delimiterIterate)) + if err != nil { + return err + } } if len(args) == 1 { k = args[0] @@ -178,7 +183,10 @@ func list(cmd *cobra.Command, args []string) error { if err != nil { return err } - db.Sync() + err = db.Sync() + if err != nil { + return err + } return db.View(func(txn *badger.Txn) error { opts := badger.DefaultIteratorOptions opts.PrefetchSize = 10