Thread: use of pager on Windows psql
psql's print.c contains this piece of code: /** PageOutput** Tests if pager is needed and returns appropriate FILE pointer.*/ FILE * PageOutput(int lines, unsigned short int pager) { /* check whether we need / can / are supposed to use pager */ if (pager #ifndef WIN32 && isatty(fileno(stdin)) && isatty(fileno(stdout)) #endif ) { Why are we not doing the isatty tests on Windows? We can and do use isatty on Windows elsewhere, so I'm a bit mystified about this. In fact, it looks to me like it would be much more sensible to #include "settings.h" and then simply test pset.notty for all platforms. cheers andrew
Andrew Dunstan wrote: > > psql's print.c contains this piece of code: > > /* > * PageOutput > * > * Tests if pager is needed and returns appropriate FILE pointer. > */ > FILE * > PageOutput(int lines, unsigned short int pager) > { > /* check whether we need / can / are supposed to use pager */ > if (pager > #ifndef WIN32 > && > isatty(fileno(stdin)) && > isatty(fileno(stdout)) > #endif > ) > { > > > > Why are we not doing the isatty tests on Windows? We can and do use > isatty on Windows elsewhere, so I'm a bit mystified about this. Not sure why ware are not. Should we enabled that code on Win32 and see how it works? Can you test it? Was it some MinGW limitation? I do see isatty() being used on lots of platforms. This is kind of odd. Ah, I bet it came from libpq's PQprint(), which I think we had working on Win32 long before we had psql working and perhaps I copied it from there. I don't see the Win32 checks around isatty() anywhere else. > In fact, it looks to me like it would be much more sensible to #include > "settings.h" and then simply test pset.notty for all platforms. Yes, we could do that but does the isatty() value ever change while psql is running? When you do '\g filename' does stdout then have isatty as false? -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Bruce Momjian wrote: > Andrew Dunstan wrote: > >> psql's print.c contains this piece of code: >> >> /* >> * PageOutput >> * >> * Tests if pager is needed and returns appropriate FILE pointer. >> */ >> FILE * >> PageOutput(int lines, unsigned short int pager) >> { >> /* check whether we need / can / are supposed to use pager */ >> if (pager >> #ifndef WIN32 >> && >> isatty(fileno(stdin)) && >> isatty(fileno(stdout)) >> #endif >> ) >> { >> >> >> >> Why are we not doing the isatty tests on Windows? We can and do use >> isatty on Windows elsewhere, so I'm a bit mystified about this. >> > > Not sure why ware are not. Should we enabled that code on Win32 and see > how it works? Can you test it? Was it some MinGW limitation? I do see > isatty() being used on lots of platforms. > > This is kind of odd. Ah, I bet it came from libpq's PQprint(), which I > think we had working on Win32 long before we had psql working and > perhaps I copied it from there. I don't see the Win32 checks around > isatty() anywhere else. > > >> In fact, it looks to me like it would be much more sensible to #include >> "settings.h" and then simply test pset.notty for all platforms. >> > > Yes, we could do that but does the isatty() value ever change while psql > is running? When you do '\g filename' does stdout then have isatty as > false? > Good point. I think the best thing would just be to remove the #ifndef WIN32 / #endif lines cheers andrew