sprig
sprig copied to clipboard
"abbrev" and "abbrevboth" don't respect width limit
Background and Issue
Let's use abbrev as example, abbrev 3 "hello world" gives us "hello world", because of line https://github.com/Masterminds/sprig/blob/4241ae82dd07e5d3391a83c25b79c04450eb22b0/strings.go#L39-L41
This happens silently, and may be misleading (my intuitive expectation for abbrev 3 "hello world" would never be complete original string).
In the underlying dependency goutils, actually the min width is specified (minimum width is 4), and usage like abbrev 3 "hello world" will result in error, https://github.com/Masterminds/goutils/blob/master/stringutils.go#L71-L73
Suggestion
Shall we simply follow the limits specified in goutils? And raise exceptions from goutils
Similar issue and suggestion for abbrevboth.