From d844b8dc227a1d06840d717f21fb873d5f12ab52 Mon Sep 17 00:00:00 2001 From: sammyette Date: Tue, 11 Jul 2023 13:45:18 -0400 Subject: [PATCH] fix: crashes on alias arg substitution - ignore 0 index in arg substitution - fix out of bounds check --- aliases.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aliases.go b/aliases.go index a440f90..258f3e6 100644 --- a/aliases.go +++ b/aliases.go @@ -54,12 +54,12 @@ func (a *aliasModule) Resolve(cmdstr string) string { for a.aliases[args[0]] != "" { alias := a.aliases[args[0]] alias = arg.ReplaceAllStringFunc(alias, func(a string) string { - if strings.HasPrefix(a, "\\") { + idx, _ := strconv.Atoi(a[1:]) + if strings.HasPrefix(a, "\\") || idx == 0 { return strings.TrimPrefix(a, "\\") } - idx, _ := strconv.Atoi(a[1:]) - if idx > len(args) { + if idx + 1 > len(args) { return a } val := args[idx]