convertCmdStrToCmdArray checks if cmd string is blank (whitespace included) then returns empty string array, else returns the split word array of cmd. This is to ensure the result will never be []string{""}
(cmd string)
| 253 | // then returns empty string array, else returns the split word array of cmd. |
| 254 | // This is to ensure the result will never be []string{""} |
| 255 | func convertCmdStrToCmdArray(cmd string) []string { |
| 256 | var cmdArray []string |
| 257 | trimmedCmdStr := strings.TrimSpace(cmd) |
| 258 | if trimmedCmdStr != "" { |
| 259 | cmdArray = strings.Split(trimmedCmdStr, " ") |
| 260 | } |
| 261 | return cmdArray |
| 262 | } |