| 125 | func expandSkillHome(path string) string { |
| 126 | if path == "~" { |
| 127 | if home := skillHomeDir(); home != "" { |
| 128 | return home |
| 129 | } |
| 130 | } |
| 131 | if strings.HasPrefix(path, "~/") { |
| 132 | if home := skillHomeDir(); home != "" { |
| 133 | return filepath.Join(home, path[2:]) |
| 134 | } |
| 135 | } |
| 136 | return path |
| 137 | } |
| 138 | |
| 139 | func skillHomeDir() string { |
| 140 | if home := strings.TrimSpace(os.Getenv("HOME")); home != "" { |
| 141 | return home |
| 142 | } |
| 143 | home, _ := os.UserHomeDir() |
| 144 | return home |
| 145 | } |
| 146 | |
| 147 | func uniqueExistingOrder(paths []string) []string { |
| 148 | seen := map[string]struct{}{} |
| 149 | out := make([]string, 0, len(paths)) |
| 150 | for _, path := range paths { |
| 151 | if path == "" { |