I am trying to add an Windows AltRoot to my p4 client automatically in command line without needing to edit the client form interactively. I am doing this from a Linux machine. Below is the command I tried:
p4 client -o | sed "s@AltRoot:@AltRoot:\n\tN:\\\path\\\to\\\the\\\client@" | p4 client -i
However, p4 client is recognizing the drive number N:
as an invalid p4 client field name.
How do we get around this?
Use the --field
global option to edit the fields produced by a <spec> -o
command. This option uses the built-in spec parser so you don't need to fiddle with regexes.
You can then pipe the result directly to p4 client -i
:
C:\Perforce\test>p4 --field AltRoots+=N:\path\to\the\client client -o | p4 client -i
Client Samwise-dvcs-1509687817 saved.
C:\Perforce\test>p4 client -o | grep -A1 AltRoots
# AltRoots: Up to two alternate client workspace roots.
# Options: Client options:
--
AltRoots:
N:\path\to\the\client