fix: stdin TTY 偵測改以 fd 0 實際裝置判定,escript 真終端機不再誤判(issue #19)
- 新增 BearCli.TTY:readlink /proc/self/fd/0 判定 pts/tty/console/ptmx; 無 /proc 平台退回 :io.rows/0 - vault/self_service 的 tty_stdin?、accounts 的 tty? 改用 TTY.stdin_tty? - 根因::io.rows/0/:io.columns/0 走 io 協定問 group leader,escript (noshell standard_io)不支援行列查詢,一律回 enotsup——真終端機被 誤判成非 TTY,互動指令(vault unlock 等)無法讀 stdin 密碼 (bear #52 驗收建議 2) - 非 TTY(pipe/redirect)行為不變:明確提示+退出碼 2 - 新增 tty_test(4 測試);mix precommit 全綠(200 passed)
This commit is contained in:
@@ -21,6 +21,7 @@ defmodule BearCli.Accounts do
|
||||
|
||||
import BearCli.Admin, only: [context: 1, fail: 3, format_api_error: 2]
|
||||
alias BearCli.Api
|
||||
alias BearCli.TTY
|
||||
|
||||
@list_per_page_fetch 100
|
||||
@max_fetch_pages 50
|
||||
@@ -251,8 +252,10 @@ defmodule BearCli.Accounts do
|
||||
|
||||
defp weak_password?(_), do: true
|
||||
|
||||
# stdin 是否為 TTY:優先以 fd 0 實際裝置判定(escript 環境 :io.columns/0
|
||||
# 一律 enotsup,真終端機會被誤判;見 BearCli.TTY,issue #19)。
|
||||
defp tty? do
|
||||
:io.columns() != {:error, :enotsup}
|
||||
TTY.stdin_tty?()
|
||||
end
|
||||
|
||||
defp prompt_password(prompt) do
|
||||
|
||||
Reference in New Issue
Block a user