Expand "~" to home directory when specifying ssh identity file

This commit is contained in:
2024-07-09 17:23:36 -04:00
parent 20c70bac9e
commit 9614ffc513
2 changed files with 12 additions and 5 deletions
+8 -2
View File
@@ -3,10 +3,11 @@ package cli
import (
"bufio"
"fmt"
"github.com/rwinkhart/MUTN/src/backend"
"golang.org/x/crypto/ssh/terminal"
"os"
"strings"
"github.com/rwinkhart/MUTN/src/backend"
"golang.org/x/crypto/ssh/terminal"
)
// input prompts the user for input and returns the input as a string
@@ -76,3 +77,8 @@ func writeEntryCLI(targetLocation string, unencryptedEntry []string, hideSecrets
os.Exit(1)
}
}
// expandPathWithHome, given a path (as a string) containing "~", returns the path with "~" expanded to the user's home directory
func expandPathWithHome(path string) string {
return strings.Replace(path, "~", backend.Home, 1)
}