diff --git a/cmake/modules/ConfigureChecks.cmake b/cmake/modules/ConfigureChecks.cmake index 4caccfbc5f8..62fc96f169a 100644 --- a/cmake/modules/ConfigureChecks.cmake +++ b/cmake/modules/ConfigureChecks.cmake @@ -192,15 +192,18 @@ check_symbol_exists (vsnprintf stdio.h HAVE_VSNPRINTF_) if (HAVE_UNISTD_H_) check_symbol_exists (access unistd.h HAVE_ACCESS) check_symbol_exists (getpid unistd.h HAVE_GETPID) + check_symbol_exists (isatty unistd.h HAVE_ISATTY) else (HAVE_UNISTD_H_) # in MinGW: check_symbol_exists (access io.h HAVE_ACCESS) check_symbol_exists (_getpid process.h HAVE__GETPID) + check_symbol_exists (isatty io.h HAVE_ISATTY) endif (HAVE_UNISTD_H_) if (WIN32) check_symbol_exists (_access io.h HAVE__ACCESS) check_symbol_exists (_fileno stdio.h HAVE__FILENO) + check_symbol_exists (_isatty io.h HAVE__ISATTY) check_symbol_exists (_getcwd direct.h HAVE__GETCWD) check_symbol_exists (_mkdir direct.h HAVE__MKDIR) check_symbol_exists (_setmode io.h HAVE__SETMODE) diff --git a/src/gmt_api.c b/src/gmt_api.c index 3fd158db1c7..7161b2dec29 100644 --- a/src/gmt_api.c +++ b/src/gmt_api.c @@ -7868,6 +7868,9 @@ GMT_LOCAL int gmtapi_init_import (struct GMTAPI_CTRL *API, enum GMT_enum_family /* Note that n_reg can have changed if we added file args above */ if ((mode & GMT_ADD_STDIO_ALWAYS) || ((mode & GMT_ADD_STDIO_IF_NONE) && n_reg == 0)) { /* Wish to register stdin pointer as a source */ + if (n_reg == 0 && isatty (fileno (API->GMT->session.std[GMT_IN]))) + GMT_Report (API, GMT_MSG_WARNING, "No input file given - reading table data from standard input (this terminal). " + "Type your data and press Ctrl-D when done. To use a file or a pipe instead, press Ctrl-C now and rerun the command with that input.\n"); if ((object_ID = GMT_Register_IO (API, family|GMT_VIA_MODULE_INPUT, GMT_IS_STREAM, geometry, GMT_IN, NULL, API->GMT->session.std[GMT_IN])) == GMT_NOTSET) return_value (API, API->error, GMT_NOTSET); /* Failure to register stdin */ n_reg++; /* Add the single item */ diff --git a/src/gmt_config.h.in b/src/gmt_config.h.in index 339c6d2d559..030a8f2f58e 100644 --- a/src/gmt_config.h.in +++ b/src/gmt_config.h.in @@ -100,6 +100,8 @@ #cmakedefine HAVE_FCNTL #cmakedefine HAVE_FILENO #cmakedefine HAVE__FILENO +#cmakedefine HAVE_ISATTY +#cmakedefine HAVE__ISATTY #cmakedefine HAVE_FSEEKO #cmakedefine HAVE_FTELLO #cmakedefine HAVE__FSEEKI64 diff --git a/src/gmt_notposix.h b/src/gmt_notposix.h index 333467fbe0b..168965cf6c3 100644 --- a/src/gmt_notposix.h +++ b/src/gmt_notposix.h @@ -495,6 +495,13 @@ # define fileno _fileno #endif +/* isatty is usually in unistd.h; we use a macro here + * since the same function under WIN32 is prefixed with _ + * and defined in io.h */ +#if defined HAVE__ISATTY && !defined HAVE_ISATTY +# define isatty _isatty +#endif + /* rmdir is usually in unistd.h; we use a macro here * since the same function under WIN32 is prefixed with _ * and defined in direct.h */