[p4] p4 submit w/o an editor

Chuck Karish chuck.karish at gmail.com
Sat Jul 15 11:30:49 PDT 2006


On 7/14/06, Weintraub, David <david.weintraub at bofasecurities.com> wrote:
> * Inability to run commands without creating forms

CVS doesn't have the capabilities for which Perforce uses forms:
managing collections of files through views.  Most forms-using
Perforce subcommands can be programmed simply with this
 pattern:

  p4 <subcommand> -o | <your_processing_here> | p4 <subcommand> -i

> <http://www.perforce.com/perforce/doc.061/manuals/p4guide/08_scripting.h
> tml#1032869>. I've been doing Unix shell scripting for almost 20 years,
> and I had to read that a couple of times before I understood what was
> going on. I then read it a few more times because I found the whole
> thing so unbelievable.

The sample script given there could be made easier to read:

$p4 fstat -Ro $1 | while read dots name value
do
    case "$name" in
         depotFile)  depotFile=$value ;;
         headRev)  headRev=$value ;;
         haveRev)  haveRev=$value ;;
    esac

     if [ $headRev != $haveRev ]
     then
          $echo $depotFile
     fi
done

(This could also be done using 'p4 sync -n $1', but then
there'd be no sample script.)

> I shouldn't have to go through temp files or pipes to do basic commands..

As others have pointed out, whether temp files are needed depends
more on the amount of data you're processing than on anything
inherent in Perforce.  When you're programming in sh/bash/ksh
temp files are a fact of life when you have more than a few tens of
kilobytes of data to handle.  At that point it's time to use a programming
language that does memory allocation.

> * Perforce commands always returning a zero return code even when they
> "fail"

p4 could do a better job with this.  It's hard to fix this with ten years'
accumulation of customer scripts in the field, many of which would
break if the return codes were changed.  The same holds for writing
error messages to stdout rather than to stderr.

Remember, p4 is a multi-platform utility and as such should work with
comparable results on all supported platforms.  Not all of those
platforms support the semantics you expect from a Unix utility.

-- 
Chuck Karish   karish at well.com   (415) 317-0182



More information about the perforce-user mailing list