| 2933 | } |
| 2934 | |
| 2935 | static bool prompt_yn(const char *question) { |
| 2936 | if (g_auto_answer == AUTO_YES) { |
| 2937 | printf("%s (y/n): y (auto)\n", question); |
| 2938 | return true; |
| 2939 | } |
| 2940 | if (g_auto_answer == AUTO_NO) { |
| 2941 | printf("%s (y/n): n (auto)\n", question); |
| 2942 | return false; |
| 2943 | } |
| 2944 | |
| 2945 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 2946 | #ifndef _WIN32 |
| 2947 | if (!isatty(fileno(stdin))) { |
| 2948 | (void)fprintf(stderr, |
| 2949 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 2950 | return false; |
| 2951 | } |
| 2952 | #endif |
| 2953 | |
| 2954 | printf("%s (y/n): ", question); |
| 2955 | (void)fflush(stdout); |
| 2956 | |
| 2957 | char buf[CLI_BUF_16]; |
| 2958 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 2959 | return false; |
| 2960 | } |
| 2961 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 2962 | } |
| 2963 | |
| 2964 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 2965 |
no outgoing calls
no test coverage detected