Skip to content

Commit

Permalink
Bounds checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchpaulus committed Dec 11, 2024
1 parent 00469da commit 64a5541
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mshell/MShellObject.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,16 @@ func (obj *MShellBool) IndexErrStr() string {
}

func (obj *MShellQuotation) IndexErrStr() string {
if len(obj.Tokens) == 0 {
return ""
}
return fmt.Sprintf(" Last item: %s", obj.Tokens[len(obj.Tokens)-1].DebugString())
}

func (obj *MShellList) IndexErrStr() string {
if len(obj.Items) == 0 {
return ""
}
return fmt.Sprintf(" Last item: %s", obj.Items[len(obj.Items)-1].DebugString())
}

Expand All @@ -399,6 +405,9 @@ func (obj *MShellString) IndexErrStr() string {
}

func (obj *MShellPipe) IndexErrStr() string {
if len(obj.List.Items) == 0 {
return ""
}
return fmt.Sprintf(" Last item: %s", obj.List.Items[len(obj.List.Items)-1].DebugString())
}

Expand Down

0 comments on commit 64a5541

Please sign in to comment.