Commit 195818ad authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

userFileOverwrite: check tty mode

parent 4bac6d49
......@@ -280,11 +280,11 @@ void cdo_init_is_tty(void)
{
struct stat statbuf;
fstat(0, &statbuf);
if ( S_ISCHR(statbuf.st_mode) ) stdin_is_tty = 1;
if ( S_ISCHR(statbuf.st_mode) ) stdin_is_tty = 1;
fstat(1, &statbuf);
if ( S_ISCHR(statbuf.st_mode) ) stdout_is_tty = 1;
if ( S_ISCHR(statbuf.st_mode) ) stdout_is_tty = 1;
fstat(2, &statbuf);
if ( S_ISCHR(statbuf.st_mode) ) stderr_is_tty = 1;
if ( S_ISCHR(statbuf.st_mode) ) stderr_is_tty = 1;
}
static
......@@ -1388,6 +1388,13 @@ int main(int argc, char *argv[])
if ( Debug || Version ) cdo_version();
if ( Debug )
{
fprintf(stderr, "stdin_is_tty: %d\n", stdin_is_tty);
fprintf(stderr, "stdout_is_tty: %d\n", stdout_is_tty);
fprintf(stderr, "stderr_is_tty: %d\n", stderr_is_tty);
}
if ( Debug ) print_system_info();
check_stacksize();
......
......@@ -521,7 +521,7 @@ int userFileOverwrite(const char *restrict filename)
{
int status = 0;
if ( stdin_is_tty )
if ( stdin_is_tty && stderr_is_tty )
{
fprintf(stderr, "File %s already exists, overwrite? (yes/no): ", filename);
char line[1024];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment