Search code examples
clearcasequotes

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


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?


Solution

  • 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.