| 7856 | } |
| 7857 | |
| 7858 | static bool prompt_yn(const char *question) { |
| 7859 | if (g_auto_answer == AUTO_YES) { |
| 7860 | printf("%s (y/n): y (auto)\n", question); |
| 7861 | return true; |
| 7862 | } |
| 7863 | if (g_auto_answer == AUTO_NO) { |
| 7864 | printf("%s (y/n): n (auto)\n", question); |
| 7865 | return false; |
| 7866 | } |
| 7867 | |
| 7868 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 7869 | #ifndef _WIN32 |
| 7870 | if (!isatty(fileno(stdin))) { |
| 7871 | (void)fprintf(stderr, |
| 7872 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 7873 | return false; |
| 7874 | } |
| 7875 | #endif |
| 7876 | |
| 7877 | printf("%s (y/n): ", question); |
| 7878 | (void)fflush(stdout); |
| 7879 | |
| 7880 | char buf[CLI_BUF_16]; |
| 7881 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 7882 | return false; |
| 7883 | } |
| 7884 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 7885 | } |
| 7886 | |
| 7887 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 7888 |
no outgoing calls
no test coverage detected