From a47fe37a97b93911b4509636888018fa18de500d Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Tue, 3 Nov 2020 14:59:03 -0700 Subject: Use regex for "pod ps" name filter to match "ps" behavior Signed-off-by: Joel Smith --- libpod/filters/pods.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/filters/pods.go b/libpod/filters/pods.go index adce9784c..0caa941dd 100644 --- a/libpod/filters/pods.go +++ b/libpod/filters/pods.go @@ -1,6 +1,7 @@ package lpfilters import ( + "regexp" "strconv" "strings" @@ -78,7 +79,11 @@ func GeneratePodFilterFunc(filter, filterValue string) ( }, nil case "name": return func(p *libpod.Pod) bool { - return strings.Contains(p.Name(), filterValue) + match, err := regexp.MatchString(filterValue, p.Name()) + if err != nil { + return false + } + return match }, nil case "status": if !util.StringInSlice(filterValue, []string{"stopped", "running", "paused", "exited", "dead", "created"}) { -- cgit v1.2.3-54-g00ecf