统一管理员重置输入提示的中文冒号
Some checks are pending
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-09-19 22:23:17 +08:00
parent 3368e4626d
commit 513ce6d619
2 changed files with 2 additions and 1 deletions

View File

@ -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)

View File

@ -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 {