ShellExpand replaces a leading "~" with the home directory" and expands all environment variables afterwards.
(s string)
| 14 | // ShellExpand replaces a leading "~" with the home directory" and |
| 15 | // expands all environment variables afterwards. |
| 16 | func ShellExpand(s string) string { |
| 17 | if s != "" { |
| 18 | if s[0] == '~' { |
| 19 | newS, err := homedir.Expand(s) |
| 20 | if err == nil { |
| 21 | s = newS |
| 22 | } |
| 23 | } |
| 24 | s = os.ExpandEnv(s) |
| 25 | } |
| 26 | return s |
| 27 | } |
| 28 | |
| 29 | // CurrentUser finds the current user name or "" if not found |
| 30 | func CurrentUser() (userName string) { |
no outgoing calls
searching dependent graphs…