sprig icon indicating copy to clipboard operation
sprig copied to clipboard

"abbrev" and "abbrevboth" don't respect width limit

Open XD-DENG opened this issue 4 years ago • 0 comments

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.

XD-DENG avatar Jan 22 '21 12:01 XD-DENG