mirror of https://github.com/Hilbis/Hilbish
fix: crashes on alias arg substitution
- ignore 0 index in arg substitution - fix out of bounds checkpull/258/head
parent
9e80b4bf50
commit
d844b8dc22
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue