Changing workspace clobber option directly from Pe

2020-03-21 02:01发布

问题:

How to change perforce specs from command line? What I want to do is, i have a workspace whose clobber option is set to noclobber(default value). Now i want to change it to clobber.

I know we can do it directly from p4v, but i dont want that. I also know that if we run 'p4 client' command in cmd, it will open P4CONFIG file in text editor, where we can change noclobber to clobber and save the file and its done, but i also dont want that too.

Please tell me the specific command which directly changes the noclobber to clobber without using p4v or without editing P4CONFIG.txt.

Thanks and Regards, Noob perforce admin

回答1:

It's pretty easy to script this with Perl, Python, Ruby, or even Powershell. Here's a one-liner in Powershell:

p4 client -o | %{$_ -replace "noclobber", "clobber"} | p4 client -i



回答2:

If you're trying to avoid repeatedly opening a text editor, you can accomplish your goal with a little bit of sed, like this:

p4 client -o | \
sed 's/ noclobber/ clobber/' | \
p4 client -i


回答3:

Simplest solution:

P4EDITOR='sed -i s/noclobber/clobber/' p4 client