Search code examples
bashshellperforceworkspace

Scripts to edit a P4 client workspace


I'm writing some script but I need to first get the source code from P4. How do I edit the client workspace in my script?

Here are the steps that I normally take using bash:

export P4CLIENT=myworkspace
p4 client
//now I manually edit the source and destination directory using Vim
p4 sync

Thanks in advance!!!


Solution

  • p4 client can use standard input and output.

    export P4CLIENT=myworkspace
    p4 client -o > /tmp/myclient.$$ # Write client to a temp file
    # Commands to update /tmp/myclient with the changes you need
    p4 client -i < /tmp/myclient.$$
    p4 sync
    rm /tmp/myclient.$$