Search code examples
bashclearcaseconfig-spec

Can I use `setcs` to set a configspec to a variable?


Background

In clearcase, the command setcs is used in the following examples:

Change the config spec of the current view to the contents of file cspec_REL3.

cmd-context setcs cspec_REL3

Change the config spec of the view whose view tag is jackson_vu to the default config spec.

cmd-context setcs –tag jackson_vu –default

Have the view_server of the current view reread its config spec.

cmd-context setcs –current

Problem

I have a script where I am attempting to do the following:

  1. Grab the configSpec of a certain view that I generated earlier in the script (with the first line edited out).
  2. Remove the line in the configspec that says "element * CHECKEDOUT" (I used this method)
  3. Set that view's configSpec to the new edits I made.

Below is the code I wrote to attempt this:

configSpec=`cleartool catcs -tag $VIEW_NAME | tail -n +2`
noCheckout=`printf '%s\n' "{$configSpec//element * CHECKEDOUT/}"`
cleartool setcs -tag $VIEW_NAME $noCheckout

It returns the given error:

cleartool: Error: Extra arguments: "SET:"

which just so happens to be the first word in the noCheckout variable.

Question

How can I edit and update the configspec using a string variable as an intermediary?


Solution

  • I would recommend, instead of using a string variable as an intermediary, to use a file, since cleartool setcs pname is:

    pname
    Specifies a text file whose contents are to become the view's new config spec.

    So, if you can, redirect the content of your variable to a file (fprintf), and use that per-determined filename as argument of your setcs command.