From f7d867ef146d776a8f1361e83019d9e2c437670b Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Sun, 10 May 2020 14:27:11 -0400 Subject: fixed bug in userCountQuery was only returning a single user when there were multiple users. moved to absolute path for ls and strings.Fields(). --- usercount.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usercount.go b/usercount.go index ff35463..a7084f1 100644 --- a/usercount.go +++ b/usercount.go @@ -9,12 +9,12 @@ import ( // Just returns the number of directories in /home // The assumption being, it's the number of human users. func userCountQuery(format string) ([]byte, error) { - ls, err := exec.Command("ls", "/home").Output() + ls, err := exec.Command("/bin/ls", "/home").Output() if err != nil { return nil, fmt.Errorf("Couldn't execute ls: %w", err) } - split := strings.Split(string(ls), " ") + split := strings.Fields(string(ls)) if format == "plain" { return []byte(fmt.Sprintf("%v users", len(split))), nil -- cgit 1.4.1-2-gfad0