This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Bash: when is WinXP not WinXP??
"Dave Korn" <dk@artimi.com> wrote in
NUTMEGd8PXibjXt5tX800000407@NUTMEG.CAM.ARTIMI.COM:">news:NUTMEGd8PXibjXt5tX800000407@NUTMEG.CAM.ARTIMI.COM:
>> -----Original Message-----
>> From: cygwin-owner On Behalf Of Daniel Miller
>> Sent: 12 October 2004 19:06
>
>> under Bash. Under WXPPro/Bash it worked fine. However, under Home
>> edition, my utility apparently thinks its output is being
>> redirected, so it tries to generate the output as html code
>> (to preserve colors), which of course generates tons of garbage.
>
> Then your code has a bug. Whatever technique it is using to decide
> if it
> is being redirected is wrong. In fact, I'd go so far as to say that
> changing your output format if you think you're being redirected is
> wrong full stop. Let the output format be under control of a
> command-line switch. If someone is going to decide to redirect the
> output, they can decide to give the option for html output as well.
>
Well, the code that's causing me to think I'm redirected is:
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
PERR(hStdOut != INVALID_HANDLE_VALUE, "GetStdHandle");
bSuccess = GetConsoleScreenBufferInfo(hStdOut, &sinfo) ;
if (bSuccess == false) {
// this returned "The handle is invalid"
fprintf(stderr, "gcsbi error: %s\n", get_system_message()) ;
exit(1) ;
redirected = 1 ;
return ;
}
So even if I did as you suggest above, I would still have to terminate my
program when GetConsoleScreenBufferInfo failed... Now *why* is that
function failing on hStdOut, which was not itself invalid (since
GetStdHandle succeeded)... ?? And again, why only on the Home machine,
not on the Pro machine??
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/