Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors and warnings lost when redirecting output to files in a shell #64

Open
GoogleCodeExporter opened this issue Aug 23, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

How to find a warning:

donny@donny-desktop:~/src/hg/gpsee$ gsr -c 'warning=42'
JS strict warning #156 in command_line at line 1 - assignment to undeclared
variable warning

How to lose a warning:
donny@donny-desktop:~/src/hg/gpsee$ gsr -c 'warning=42' &> log
donny@donny-desktop:~/src/hg/gpsee$ cat log

I was giving nickg some code to run to help evaluate a bug report, but then
I discovered the bug I'm reporting here now. The code below demonstrates my
proposed use case, and the reason I think the current behavior is a bug:

RESULTFILE=bugreport.txt
(hg id                           &&
make clean                       &&
make build                       &&
make install                     &&
echo @testing /tmp/foo           ;
gsr -c 'require("/tmp/foo")'     ;
echo @testing /tmp/foo.js        ;
gsr -c 'require("/tmp/foo.js")'
)                                &> $RESULTFILE

Also -d doesn't help:

donny@donny-desktop:~/src/hg/gpsee$ gsr -c 'require("/foo/js")' &> f
donny@donny-desktop:~/src/hg/gpsee$ cat f
donny@donny-desktop:~/src/hg/gpsee$ gsr -dc 'require("/foo/js")' &> f
donny@donny-desktop:~/src/hg/gpsee$ cat f
donny@donny-desktop:~/src/hg/gpsee$ gsr -ddc 'require("/foo/js")' &> f
donny@donny-desktop:~/src/hg/gpsee$ cat f
donny@donny-desktop:~/src/hg/gpsee$ gsr -dddc 'require("/foo/js")' &> f
donny@donny-desktop:~/src/hg/gpsee$ cat f

I will take a look at this and try to ensure that -d will output the same
error and warning output even if the stderr is not a tty.

Wes please let me know if my intentions are pure and good.

Original issue reported on code.google.com by donny.vi...@gmail.com on 19 Apr 2010 at 2:01

@GoogleCodeExporter
Copy link
Author

The basic problem is that:

1. -c and preload processing is independent of -d levels
2. Warnings and errors are reported on stderr
3. -c & preload sets a non-zero debug level only when stderr is not a TTY 
(assumption
is that you are running from cron or something)
4. You are redirecting stderr 

Generally speaking, we don't want errors and warnings going to non-TTY device 
unless
explicitly requested with a raised debug level -- however, you are using -c 
which is
debug-level agnostic.

So, we have two cases: 
 - people want -c to have a different-than-script debug level so that -c gives error
output when used alone
 - people want -c to have the same-as-script debug level so that -d causes -c to put
output out stderr

Frankly, my immediate thought is to remove -c entirely, because we keep wasting 
time
on it when it and it is confusing people. Confusing, conflicting features and
spaghetti code generally don't make for good software.

Original comment by wes%page...@gtempaccount.com on 19 Apr 2010 at 12:38

@GoogleCodeExporter
Copy link
Author

I've had some more thoughts about this code, hopefully I'm a little clearer now 
that
that migraine is gone.

We need to decide if -c is going to get the same error handling as the main 
program
or not.  If so, we need to refactor gsr.c to get processFlags() happening 
before the
-c code is executed. This may mean an extra getopt loop.

We also need to consider the case where users truly want debug output on their
non-tty outputs.  What do you think about a -T flag which means "treat stderr 
and
stdout as tty, whether they are or not?"

Original comment by wes%page...@gtempaccount.com on 23 Apr 2010 at 2:13

@GoogleCodeExporter
Copy link
Author

Original comment by wes@page.ca on 5 Sep 2012 at 3:24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant