6

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 I can do it directly from p4v, but I don't want that. I also know that if I run p4 client, it will open P4CONFIG file in text editor, where I can change noclobber to clobber and save the file and it's done, but I also don't want that.

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

Community
  • 1
  • 1
Niyojan
  • 544
  • 1
  • 6
  • 23
  • When you call 'p4 client' you will edit the options of the one particular client that you're working with. It doesn't affect any other clients. Why is that not sufficient in your case? I don't know of any other way to do that. – pitseeker Apr 29 '13 at 12:01

3 Answers3

4

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
Victor Yarema
  • 1,183
  • 13
  • 15
Eric Miller
  • 1,944
  • 16
  • 12
  • I am not able to run this command in Win 7 command line promt. Is this a windows command, or should i make a bat file of this and run that? – Niyojan Apr 30 '13 at 03:13
  • @Niyojan, this is shell (usually `bash`) command. You can run it from any `bash`, `zsh` on windows. You can use `bash` from https://git-scm.com/download/win for example. Or you can even use more powerful https://www.cygwin.com/ (I would recommend to use 64bits version to avoid problems with 32bits version on 64bits windows). – Victor Yarema May 17 '19 at 08:21
  • You can also just download a copy of `sed` for Windows that will work with any shell, including `cmd`. Googling "sed for windows" gets me this as the first hit, seems legit: http://gnuwin32.sourceforge.net/packages/sed.htm – Samwise Mar 14 '21 at 19:25
2

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

randy-wandisco
  • 3,649
  • 16
  • 11
0

Simplest solution:

P4EDITOR='sed -i s/noclobber/clobber/' p4 client
Michel Samia
  • 4,273
  • 2
  • 24
  • 24
  • 2
    Could you please add a little bit more details about `P4EDITOR` env var? How exactly does it work? – Victor Yarema May 17 '19 at 08:28
  • `P4EDITOR` defines the editor program that's used to edit forms for all p4 commands. If you use this method, make sure to unset it afterwards, or you'll be largely unable to use `p4`. IMO it's better to just do `p4 client -o | sed s/noclobber/clobber/ | p4 client -i`. – Samwise Mar 14 '21 at 19:22