cmdBase returns the base name of a command path, handling both forward and back slashes since commands may originate from Windows workspaces while this code runs on a Linux server.
(prog string)
| 82 | // forward and back slashes since commands may originate from Windows |
| 83 | // workspaces while this code runs on a Linux server. |
| 84 | func cmdBase(prog string) string { |
| 85 | if i := strings.LastIndexAny(prog, `/\`); i >= 0 { |
| 86 | return prog[i+1:] |
| 87 | } |
| 88 | return prog |
| 89 | } |
| 90 | |
| 91 | // firstNonFlagLiteral returns the literal value of the first word in |
| 92 | // ws that does not start with "-", or "" if none qualifies. |