This commit is contained in:
parent
3368e4626d
commit
513ce6d619
@ -46,6 +46,7 @@ func ReadVisibleInput(prompt string) (string, error) {
|
||||
}
|
||||
|
||||
func readSystemdInput(prompt, echo string) (string, error) {
|
||||
prompt = strings.TrimRight(prompt, ":: ") + ":"
|
||||
// systemd 代理把提示保存在单行配置中,用终端换行控制显示列表,避免配置被拆行。
|
||||
prompt = strings.ReplaceAll(strings.ReplaceAll(prompt, "\r\n", "\n"), "\n", "\x1bE")
|
||||
command := exec.Command("systemd-ask-password", "--no-tty", "--echo="+echo, prompt)
|
||||
|
||||
@ -40,7 +40,7 @@ func readWindowsPassword(prompt string) (string, error) {
|
||||
if !term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
return "", errors.New("受保护的密码输入需要交互式控制台")
|
||||
}
|
||||
fmt.Fprint(os.Stderr, prompt+": ")
|
||||
fmt.Fprint(os.Stderr, strings.TrimRight(prompt, ":: ")+": ")
|
||||
valueBytes, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
fmt.Fprintln(os.Stderr)
|
||||
if err != nil {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user