[p4] what's the best way to determine the current client workspace?

Jay Glanville Jay.Glanville at naturalconvergence.com
Wed Jun 27 12:00:04 PDT 2007


I want to write a script that calls a perforce command where one of the
arguments is the name of the current workspace.  The desired output of
the command is the latest change list number on the current hard drive.
In other words, I want to execute the following command:

    p4 changes -m 1 \
      //branch_name/...@[current_workspace] | \
      sed 's/Change \([0-9]*\).*/\1/'

Where [current_workspace] is the name of the current workspace.  My
question is this: what is the best way to determine what is the current
workspace?  My original thought was to parse the client spec, something
like this:

    p4 client -o | \
      sed 's/^Client: *\([a-zA-Z_0-9]*\).*/\1/'

(I know that this sed won't actually work, but you get the idea).

So, is this the best way?  Is there a better way?  Is there a direct way
to do this (by that, I mean simply ask p4 directly 'what is the current
workspace')?

Thanks

JDG

---
Jay Dickon Glanville



More information about the perforce-user mailing list