mirror of
https://codeberg.org/vyivel/dulcepan/
synced 2025-03-12 18:59:15 +02:00
main: refuse to dump the result into tty
Closes: https://codeberg.org/vyivel/dulcepan/issues/17
This commit is contained in:
parent
c343fc1f73
commit
d2620c60c5
14
src/main.c
14
src/main.c
@ -1,6 +1,7 @@
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-client-core.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
@ -167,8 +168,9 @@ static void help(const char *prog) {
|
||||
" -o <path> Specify the output file path.\n"
|
||||
"\n"
|
||||
"If the output file path is not specified, the resuling image will be printed to\n"
|
||||
"the standard output. If the output file format is not specified, it is guessed\n"
|
||||
"from the output file path if it's specified, and assumed to be PNG otherwise.\n"
|
||||
"the standard output, which is expected to not be a terminal. If the output file\n"
|
||||
"format is not specified, it is guessed from the output file path if it's\n"
|
||||
"specified, and assumed to be PNG otherwise.\n"
|
||||
"\n"
|
||||
"Supported formats: png, ppm.\n"
|
||||
"\n"
|
||||
@ -210,6 +212,14 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (state.output_path == NULL && isatty(STDOUT_FILENO)) {
|
||||
fprintf(stderr,
|
||||
"Refusing to run as the standard output is a terminal and there's no output file\n"
|
||||
"path specified.\n\n");
|
||||
help(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (state.output_format == DP_FILE_UNKNOWN) {
|
||||
if (state.output_path != NULL) {
|
||||
const char *ext = dp_ext_from_path(state.output_path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user