Skip to content

Commit

Permalink
fix: convert bash format paths only when outputting the environment
Browse files Browse the repository at this point in the history
fix #292
  • Loading branch information
aooohan committed May 28, 2024
1 parent 1428d6c commit e4a1e47
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions internal/env/windows_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,25 @@ func NewEnvManager(vfConfigPath string) (Manager, error) {
}

func (p *Paths) String() string {

if os.Getenv(HookFlag) == "bash" {
return strings.Join(p.Slice(), ":")
pps := p.Slice()
paths := make([]string, len(pps))
for _, path := range pps {
path = filepath.ToSlash(path)
// Convert drive letter (e.g., "C:") to "/c"
if len(path) > 1 && path[1] == ':' {
path = "/" + strings.ToLower(string(path[0])) + path[2:]
}
paths = append(paths, path)
}
return strings.Join(paths, ":")
} else {
return strings.Join(p.Slice(), ";")
}
}

func (p *Paths) Add(path string) bool {
if os.Getenv(HookFlag) == "bash" {
path = filepath.ToSlash(path)
// Convert drive letter (e.g., "C:") to "/c"
if len(path) > 1 && path[1] == ':' {
path = "/" + strings.ToLower(string(path[0])) + path[2:]
}
} else {
path = filepath.FromSlash(path)
}
path = filepath.FromSlash(path)
return p.SortedSet.Add(path)
}

0 comments on commit e4a1e47

Please sign in to comment.