| 6978 | } |
| 6979 | |
| 6980 | static bool prompt_yn(const char *question) { |
| 6981 | if (g_auto_answer == AUTO_YES) { |
| 6982 | printf("%s (y/n): y (auto)\n", question); |
| 6983 | return true; |
| 6984 | } |
| 6985 | if (g_auto_answer == AUTO_NO) { |
| 6986 | printf("%s (y/n): n (auto)\n", question); |
| 6987 | return false; |
| 6988 | } |
| 6989 | |
| 6990 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 6991 | #ifndef _WIN32 |
| 6992 | if (!isatty(fileno(stdin))) { |
| 6993 | (void)fprintf(stderr, |
| 6994 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 6995 | return false; |
| 6996 | } |
| 6997 | #endif |
| 6998 | |
| 6999 | printf("%s (y/n): ", question); |
| 7000 | (void)fflush(stdout); |
| 7001 | |
| 7002 | char buf[CLI_BUF_16]; |
| 7003 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 7004 | return false; |
| 7005 | } |
| 7006 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 7007 | } |
| 7008 | |
| 7009 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 7010 |
no outgoing calls
no test coverage detected