info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] cvs diff exit status


From: Donald Sharp
Subject: Re: [PATCH] cvs diff exit status
Date: Fri, 1 Dec 2000 11:12:55 -0500
User-agent: Mutt/1.2.4i

I actually tried to implement this first.  But I gave up( for the time 
being ).  There were two problems that I found:

1)  error.c and main.c insist on exit()'ing the program with 
EXIT_FAILURE.  In the long run this is a fixable problem( I understand
that systems like vms only allow success or failure, but we could
easily put some code in there that reduces the exit status to
nominal values for vms )...

2)  diff() - among other things calls tag_check_valid().  If tag_check_valid()
discovers a problem it calls error( 1 ... ).  Which would cause the 
program to exit( 1 )( Which is not the error code we would want for
diff failure ).  I didn't see a good way to find and fix
( in any manner ) the error( 1... ) calls that all auxiliary functions
might call.

Thoughts?

donald


On Fri, Dec 01, 2000 at 11:04:15AM -0500, Noel L Yap wrote:
> I see.  Sorry, I had misread your email.
> 
> I agree with your comment that, ideally, cvs diff should exit with the same
> statuses (stati :-) as diff.  I haven't delved into the code as you have to 
> see
> how feasible it is, though.
> 
> Noel
> 
> 
> 
> 
> address@hidden on 2000.12.01 10:44:38
> 
> To:   address@hidden
> cc:   address@hidden
> Subject:  Re: [PATCH] cvs diff exit status
> 
> 
> 
> 
> It's not.  cvs turns the return codes from the diff() function into
> useless information:
> 
> from main.c( I'm adding in my comments ):
>      /* call the diff() function */
>      err = (*(cm->func)) (argc, argv);
> 
>      /* At this point err is 0 - for no diff, 1 for a diff, 2 for error */
>     /* This is exit rather than return because apparently that keeps
>        some tools which check for memory leaks happier.  */
>      /* Here we exit the program, it turns 1 and 2 into program failures */
>     exit (err ? EXIT_FAILURE : 0);
> 
> donald
> 
> On Fri, Dec 01, 2000 at 10:36:06AM -0500, Noel L Yap wrote:
> > The exit status of "cvs diff" is exactly the same as the exit status of 
> > "diff"
> > (man diff for more info).  Why not test the exit status itself:
> > cvs diff blah
> > if [ $? -lt 2 ]
> > then
> >      echo success
> > else
> >      echo failure
> > fi
> >
> >
> >
> >
> > address@hidden on 2000.12.01 09:59:07
> >
> > To:   address@hidden
> > cc:   (bcc: Noel L Yap)
> > Subject:  [PATCH] cvs diff exit status
> >
> >
> >
> >
> > When the cvs diff command is run it attempts to return one of
> > three status codes to main:
> >
> > 0 - files same
> > 1 - files different
> > 2 - Some sort of error has occurred
> >
> > main interprets and return codes > 0 as a cvs program failure.
> > I've changed diff.c to return only success or failure.  Success
> > is either the '0' or '1' state outlined above.  Failure is the
> > '2' state.
> >
> > The reason that I have done this is because the current cvs
> > code returns EXIT_FAILURE for both '1' and '2' outlined above.
> > When I run a cvs diff command and check the programs return code
> > I have no way of telling whether cvs ran successfully or cvs found
> > some diffs without parsing the output from cvs as well.
> >
> > Thanks!
> >
> > donald
> >
> >
> 
> 
> 
> 
> 
> 
> 
> This communication is for informational purposes only.  It is not intended as
> an offer or solicitation for the purchase or sale of any financial instrument
> or as an official confirmation of any transaction. All market prices, data
> and other information are not warranted as to completeness or accuracy and
> are subject to change without notice. Any comments or statements made herein
> do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
> subsidiaries and affiliates.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]