1

Background

I am trying to update all files with label LABEL_A to have the label LABEL_B. Right now I am attempting a find command as shown below:

ct find . -version 'lbtype (LABEL_A)' -exec 'cleartool mklabel (LABEL_B) $CLEARCASE_XPN'

When I enter said command, the following error is returned:

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `cleartool mklabel (LABEL_B) $CLEARCASE_XPN'

What the Documentation says

When I enter ct man query_language, the following is stated about mklabel:

Attach the label EYY6 to the version of test.c that is already labeled EYY5.

UNIX and Linux:

cleartool mklabel -ver '{lbtype(EYY5)}' EYY6 test.c
Created label "EYY6" on "test.c" version "/main/4".

However, the above documentation is the case for one specific file my case is looking at all files with an old label. This prompted my question

Question

What is the proper quoting for the argument of mklabel when attempting to update all files of specific label?

isakbob
  • 1,439
  • 2
  • 17
  • 39

2 Answers2

2

You can find example of quoting policy in "CLEARCASE_XPN not parsed as variable in ClearCase command" (2012)

But you also have the cleartool mklabel syntax itself to consider: there is no (xxx) parenthesis needed:

 ct find . -version 'lbtype(LABEL_A)' -exec 'cleartool mklabel LABEL_B "$CLEARCASE_XPN"'

And no space after lbtype and its opening (.
See examples in

label type "(LABEL_B)" not found in VOB "/vobs/le_vob"

Again: no () should be used. That means you need to create the label type first in that vob:
(see "Create label with ClearCase")

cleartool mklbtype -global -nc lbtype:LABEL_B@/vobs/le_vob

Then try again the original find - exec mklabel command.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This results in the identical error that I encountered from @paulsm4's answer: `cleartool: Error: label type "(LABEL_B)" not found in VOB "/vobs/le_vob" and no global type definition can be found.` and c`leartool: Error: Unable to create label "(LABEL_B)" on "./common/cord_sup/src/header.h" version "/main/dev/super_dev/3"` – isakbob Sep 06 '19 at 20:26
  • @isakbob I have edited my answer. Why use () around the label name though? – VonC Sep 06 '19 at 20:33
  • is it against convention to use "()" around label names? – isakbob Sep 06 '19 at 20:40
  • 3
    @isakbob in the context of mklabel, that would not be correctly interpreted. In the context of a search parameter like `lbtype`, it is useful. – VonC Sep 06 '19 at 20:44
0

I think your question is Actually:

Q: How do I handle shell metacharacters inside of a ClearCase -exec command string?

A: Try this:

ct find . -version 'lbtype (LABEL_A)' -exec 'cleartool mklabel \(LABEL_B\) $CLEARCASE_XPN'

NOTE:

You might need to escape the "$" in "$CLEARCASE_XPN", too. It depends on whether Clearcase is expecting the literal "$CLEARCASE_XPN", or the expanded shell value.

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • If I try the method in your answer I get `cleartool: error: Pathname not found "$CLEARCASE_XPN".` If I try the method you suggest afterward (with a "\" before the "S"), I get `cleartool: Error: label type "(LABEL_B)" not found in VOB "/vobs/le_vob" and no global type definition can be found.` and `cleartool: Error: Unable to create label "(LABEL_B)" on "./common/cord_sup/src/header.h" version "/main/dev/super_dev/3"` – isakbob Sep 06 '19 at 20:08