| 6727 | } |
| 6728 | |
| 6729 | static bool prompt_yn(const char *question) { |
| 6730 | if (g_auto_answer == AUTO_YES) { |
| 6731 | printf("%s (y/n): y (auto)\n", question); |
| 6732 | return true; |
| 6733 | } |
| 6734 | if (g_auto_answer == AUTO_NO) { |
| 6735 | printf("%s (y/n): n (auto)\n", question); |
| 6736 | return false; |
| 6737 | } |
| 6738 | |
| 6739 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 6740 | #ifndef _WIN32 |
| 6741 | if (!isatty(fileno(stdin))) { |
| 6742 | (void)fprintf(stderr, |
| 6743 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 6744 | return false; |
| 6745 | } |
| 6746 | #endif |
| 6747 | |
| 6748 | printf("%s (y/n): ", question); |
| 6749 | (void)fflush(stdout); |
| 6750 | |
| 6751 | char buf[CLI_BUF_16]; |
| 6752 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 6753 | return false; |
| 6754 | } |
| 6755 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 6756 | } |
| 6757 | |
| 6758 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 6759 |
no outgoing calls
no test coverage detected