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]] != "" {
|
for a.aliases[args[0]] != "" {
|
||||||
alias := a.aliases[args[0]]
|
alias := a.aliases[args[0]]
|
||||||
alias = arg.ReplaceAllStringFunc(alias, func(a string) string {
|
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, "\\")
|
return strings.TrimPrefix(a, "\\")
|
||||||
}
|
}
|
||||||
|
|
||||||
idx, _ := strconv.Atoi(a[1:])
|
if idx + 1 > len(args) {
|
||||||
if idx > len(args) {
|
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
val := args[idx]
|
val := args[idx]
|
||||||
|
|
Loading…
Reference in New Issue