From 4c9a62cb710b7e6a26c27f1a1d0ea69ffb4a7168 Mon Sep 17 00:00:00 2001 From: Lucas Mior <49657055+lucas-mior@users.noreply.github.com> Date: Fri, 27 Aug 2021 14:23:35 -0300 Subject: [PATCH] fix: remove %pistol-extra% arguments when not passed to pistol (#68) --- previewer.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/previewer.go b/previewer.go index 854f69e..fc7dddc 100644 --- a/previewer.go +++ b/previewer.go @@ -173,19 +173,21 @@ func (p *Previewer) Write(w io.Writer) (error) { // We try to convert the string found in the argument to a // number. auxInt, err := strconv.Atoi(arg[loc[2]:loc[3]]) + current := arg[loc[0]:loc[1]] if (err == nil && len(p.Extras) > auxInt) { // substitute the %pistol-extra[#]% argument in the // final CLI string. - current := arg[loc[0]:loc[1]] argAux = strings.ReplaceAll(argAux, current, p.Extras[auxInt]) } else { - continue + argAux = strings.ReplaceAll(argAux, current, "") } } } else { argAux = strings.ReplaceAll(argAux, "%pistol-filename%", replStr) } - argsOut = append(argsOut, argAux) + if(len(argAux) > 0) { + argsOut = append(argsOut, argAux) + } } if p.Command == "sh:" {