[p4] Perforce Return Codes and other headaches
Robert Cowham
robert at vaccaperna.co.uk
Thu Jun 8 23:40:32 PDT 2006
> Do other people hate the fact that the "p4" command returns a
> zero even if the command doesn't work?
Not one of my favourite features.
Perforce is rather inconsistent. It was suggested to me when I first started
developing P4OFC to do things like an fstat after a command has been
implemented and check that the result was what I was expecting. In some
cases this has been well worth it.
One extra thing from the command line:
P4 -s <command>
E.g.
C:\bruno_ws>p4 -s files //depot/main/jam/jam...
info: //depot/main/jam/jam.1#36 - delete change 582 (text)
info: //depot/main/jam/jam.1.html#4 - delete change 620 (text)
info: //depot/main/jam/jam.c#36 - edit change 721 (text)
:
info: //depot/main/jam/jamMR.html#5 - delete change 620 (text)
exit: 0
C:\bruno_ws>p4 -s files //depot/main/jam/jamasdf...
error: //depot/main/jam/jamasdf... - no such file(s).
exit: 0
Thus you can parse for "error:" and "warning:" - as you can see above exit
code is still 0 for an error situation!
This whole error checking, and also error codes thing has long been a
weakness. Also the format of return strings etc - the inability to translate
them for example without breaking lots of stuff. (Minor nit - things like
"p4 lock" returns "locking" even though at that point it is locked!). If
Perforce were to do a rewrite without worrying about breaking backward
compatibility, I think they would reconsider in this area...
> Yes, I understand that the P4Perl API has P4::Errors() and
> P4::Warnings() that allows me to test for errors and
> warnings, but that doesn't work in instances where I can't
> use the P4::Perl API, or if I am writing a shell script.
>
> This is becoming a big headache in debugging scripts because
> I'm constantly coming up with various tests to see if a
> Perforce command fails. Triggers are a big problem.
>
>
> And, while I'm venting:
>
> * When a trigger fails, why does it display STDOUT, and not
> STDERR like Subversion does? When a trigger script fails, the
> output from the error isn't being displayed because of this.
More information about the perforce-user
mailing list