July 13, 2005
Stewart Gordon wrote:
<snip>
> We are thus faced with two options:
> 
> (a) being forced to redirect errors to the same place as normal output
> (b) not being able to redirect errors at all
> 
> To me, (b) is the lesser of two evils.  (a) not only tends to be undesirable, but can be useless e.g. when using the program as a filter for Doxygen.  I refer you back here:
> 
> http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2001

Moreover, I can see people using this not-so-elegant workaround

int main() {
    try {
        ...
    } catch (Object o) {
        fwritefln(stderr, "Error: %s", o.toString);
        return 1;
    }
}

to get their programs behaving sanely by the standards of many of us. OTOH if this were made the built-in behaviour, I can't see the reverse idiom as being quite as common, but it is still available if somebody really does want it.

I don't see inflicting non-standard behaviour as the default as a Good Idea....

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- a->--- UB@ P+ L E@ W++@ N+++ o K- w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
July 13, 2005
Walter wrote:

> My only reservation for inserting the patch (to write uncaught exception
> error messages to stderr) is that I've never liked stderr. I just prefer to
> redirect the output to a file, and using stderr always seems to just confuse
> the issue rather than be helpful.

That is at the same time scary, and explanatory...
(explains why this patch hasn't gotten any priority)

I use stdout and stderr all the time, and would
prefer if D's treatment of them could be fixed ?

--anders

PS. Given any thoughts to the return code, as well ?
    (i.e. _define_ the return value of "void main()")
July 13, 2005
Deewiant wrote:

> On Windows 9x and ME, it's AFAIK impossible since the command shell
> doesn't distinguish between stderr and stdout.

Does D still support these? I thought they had massive UTF problems too?

> On the NT-based Windowses, just use 2> instead of >. This basically
> means to redirect the second handle (which happens to be stderr) instead
> of the default (which is stdout).

This is the same that I use under the various* Mac OS X shells, as well.

--anders

PS. Except for csh and tcsh, of course, as they are horribly broken.
    (http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/)
July 13, 2005
Deewiant wrote:
> Stewart Gordon wrote:
>> True, there isn't an easy way of redirecting stderr on Windows, short of
>> using a home-made or third-party utility.  We are thus faced with two
>> options:
> 
> On Windows 9x and ME, it's AFAIK impossible since the command shell
> doesn't distinguish between stderr and stdout.
<snip>

Doesn't follow.  If the command shell didn't distinguish, it would be impossible _not_ to redirect stderr if you're redirecting stdout.  As it happens, the Win9x command shell redirects stdout while leaving stderr going to the console.

But see

http://authors.phptr.com/corejava/faq.html

which provides a simple program to redirect stderr to stdout, which can then be redirected as desired.

The real solution, however, is for one of us to write or find a utility to launch a program, redirecting its stderr to a file.  I'm guessing it would be simple to do....

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- a->--- UB@ P+ L E@ W++@ N+++ o K- w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
July 13, 2005
Stewart Gordon wrote:
> Deewiant wrote:
>> Stewart Gordon wrote:
>>
>>> True, there isn't an easy way of redirecting stderr on Windows, short of using a home-made or third-party utility.  We are thus faced with two options:
>>
>>
>> On Windows 9x and ME, it's AFAIK impossible since the command shell doesn't distinguish between stderr and stdout.
> 
> <snip>
> 
> Doesn't follow.  If the command shell didn't distinguish, it would be
> impossible _not_ to redirect stderr if you're redirecting stdout. As it > happens, the Win9x command shell redirects stdout while leaving stderr
> going to the console.

Right, my wording was confusing. I was talking about redirecting only stderr whilst leaving stdout at the default. What I thought was that you could redirect stderr along with stdout, but not each separately.

And you're right - on Win9x stderr is unredirectable without tools.
July 14, 2005
In article <db2nso$309v$1@digitaldaemon.com>, Stewart Gordon says...

[snip]

>
>> On MSWind, this may be a different matter.
>
>True, there isn't an easy way of redirecting stderr on Windows, short of using a home-made or third-party utility.  We are thus faced with two options:

Where did you get that idea from. Try this ...

dir 2>err.txt >dir.txt x:\*.*

and you will find that "err.txt" contains output from stderr and "dir.txt" contains output from stdout.

This works on Win2000 and WinXP. Don't know about the older (unsupported?) ones.


July 14, 2005
qwerty wrote:
<snip>
> Where did you get that idea from. Try this ...
> 
> dir 2>err.txt >dir.txt x:\*.*
> 
> and you will find that "err.txt" contains output from stderr and "dir.txt"
> contains output from stdout.
> 
> This works on Win2000 and WinXP. Don't know about the older (unsupported?) ones.

That's half our point - the hack is specific to 2000/XP.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- a->--- UB@ P+ L E@ W++@ N+++ o K- w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
July 14, 2005
Stewart Gordon wrote:
<snip>
> True, there isn't an easy way of redirecting stderr on Windows, short of using a home-made or third-party utility.  We are thus faced with two options:
> 
> (a) being forced to redirect errors to the same place as normal output
> (b) not being able to redirect errors at all
> 
> To me, (b) is the lesser of two evils.  (a) not only tends to be undesirable, but can be useless e.g. when using the program as a filter for Doxygen.  I refer you back here:

Moreover, if some program uses stdout and stderr as appropriate, then even if the shell doesn't provide a means of redirecting stderr, one can use a tool to do this redirection.  OTOH given an arbitrary program that just writes everything to stdout, no tool can be relied upon to sift the errors from the regular output.

So preserving the distinction really is useful.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- a->--- UB@ P+ L E@ W++@ N+++ o K- w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
July 15, 2005
In article <db5a83$2a9q$1@digitaldaemon.com>, Stewart Gordon says...
>
>qwerty wrote:
><snip>
>> Where did you get that idea from. Try this ...
>> 
>> dir 2>err.txt >dir.txt x:\*.*
>> 
>> and you will find that "err.txt" contains output from stderr and "dir.txt" contains output from stdout.
>> 
>> This works on Win2000 and WinXP. Don't know about the older (unsupported?) ones.
>
>That's half our point - the hack is specific to 2000/XP.

The 'hack'?  I would have thought that any 'hack' would apply to the unsupported older Windows versions as the current Windows system support this without resorting to any 'hacks'.



July 18, 2005
> The real solution, however, is for one of us to write or find a utility to launch a program, redirecting its stderr to a file.  I'm guessing it would be simple to do....
>

Use 4DOS command shell, it works on all win32.
It uses 2> syntax too.

http://www.jpsoft.com/download.htm