Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homedir discovery improvement #80

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package main

import (
"os/user"
"path/filepath"
"regexp"

Expand Down Expand Up @@ -306,8 +305,8 @@ func main_cgi_file(file string, sig bool) {

func main_rye_repl(_ io.Reader, _ io.Writer, subc bool) {
input := " 123 " // "name: \"Rye\" version: \"0.011 alpha\""
user, _ := user.Current()
profile_path := filepath.Join(user.HomeDir, ".rye-profile")
userHomeDir, _ := os.UserHomeDir()
profile_path := filepath.Join(userHomeDir, ".rye-profile")

fmt.Println("Welcome to Rye shell. Use ls and ls\\ \"pr\" to list the current context.")

Expand Down Expand Up @@ -491,7 +490,11 @@ func execInput(input string) error {
case "cd":
// 'cd' to home with empty path not yet supported.
if len(args) < 2 {
return os.Chdir(os.Getenv("HOME"))
userHomeDir, err := os.UserHomeDir()
if err != nil {
return err
}
return os.Chdir(userHomeDir)
}
// Change the directory and return the error.
return os.Chdir(args[1])
Expand Down