Skip to content
Snippets Groups Projects
Commit c298e329 authored by Yorhel's avatar Yorhel
Browse files

Check that stdin is a tty when initializing ncurses

parent 38b2c8f0
No related branches found
No related tags found
No related merge requests found
...@@ -216,8 +216,16 @@ static void init_nc() { ...@@ -216,8 +216,16 @@ static void init_nc() {
if(term) if(term)
set_term(term); set_term(term);
ok = !!term; ok = !!term;
} else } else {
/* Make sure the user doesn't accidentally pipe in data to ncdu's standard
* input without using "-f -". An annoying input sequence could result in
* the deletion of your files, which we want to prevent at all costs. */
if(!isatty(0)) {
fprintf(stderr, "Standard input is not a TTY. Did you mean to import a file using '-f -'?\n");
exit(1);
}
ok = !!initscr(); ok = !!initscr();
}
if(!ok) { if(!ok) {
fprintf(stderr, "Error while initializing ncurses.\n"); fprintf(stderr, "Error while initializing ncurses.\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment