toolbox icon indicating copy to clipboard operation
toolbox copied to clipboard

Support overriding the HOME environment variable

Open debarshiray opened this issue 1 year ago • 0 comments

Currently, if the HOME environment variable is temporarily overriden, toolbox(1) doesn't respect it. This is likely because Go's os/user doesn't respect the variable. Instead, it could be better to use os.UserHomeDir.

package main

import (
	"fmt"
	"os"
	"os/user"
)

func main() {
	user, _ := user.Current()
	fmt.Printf("%s\n", user.HomeDir)

	userHomeDir, err := os.UserHomeDir()
	fmt.Printf("%s, %s\n", userHomeDir, err)
}
$ HOME=/tmp go run user.go
/home/rishi
/tmp, %!s(<nil>)

See the discussion from here for the original motivation.

debarshiray avatar Oct 10 '24 14:10 debarshiray