2

On creating some directories in ClearCase, I 'forgot' that the argument order was significant. I Added some directories like this:

cleartool mkdir a b -c "Some comment"

On being asked for a comment for the directories, I realised the '-c' arguemnt was in the wrong place, but assumed all would be OK, so entered Some comment twice more (for a, and b seperately). I was then asked for a comment for element '-c', and Ctrl-C'ed the command.

However, now cleartool ls shows elements a, b, and '-c'.

I cannot remove the '-c' element. I've tried the following:

cleartool rmelem "-c"   #fails, assumes the -c is the comment argument
cleartool rmelem -c "comment" -c
cleartool rmelem -c "comment" "-c"
cleartool rmelem -c "comment" ^-c    #Running on Windows, so tried Windows escape
cleartool rmelem -c "comment" \-c    #CC mimics UNIX, so tried UNIX escape
cleartool rmelem -c "comment" ^\-c   #CC mimics UNIX, but running thru Windows, so tried escaping the UNIX escape.

All fail, saying either Illegal duplicate use of flag "-c[omment]" (when not escaped), or Unable to access ... (when escaped).

One other strange thing. If I tried single quotes, ct assumed the ' was part of the element name:

> cleartool rmelem -c "Removing element '-c'" '-c'
cleartool: Error: Pathname not found: "'-c'".
GKelly
  • 3,835
  • 4
  • 38
  • 45

2 Answers2

1

Use a -- a separator between options and arguments.

See Removing ClearCase objects whose name begins with a hyphen

To remove a ClearCase object (view, VOB, element or other ClearCase objects) with a preceding hyphen (-) character, execute the cleartool command with a double-hyphen argument to prevent cleartool from interpreting the name as an option.

cleartool rmelem -- -t1.txt
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. I had a feeling it would be something simple. Just my lack of ClearCase knowledge. – GKelly Dec 06 '11 at 10:36
  • @GKelly: actually, it is a convention much broader than just for ClearCase: see http://stackoverflow.com/questions/1192180/deleting-a-badly-named-git-branch/1192194#1192194 – VonC Dec 06 '11 at 11:34
0

Since it is an element, you could alternatively played the normal "add ./ in front" trick which is the common answer to questions liked "how do I remove a file called -f" or similar, e.g. cleartool rmelem ./-c, without depending on any spesific support from cleartool with -- like already mentioned by VonC. Removing a branch named -c on the other hand will need this.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
  • That's what I actually did in the end. However, I accepted VonC's answer as that explained a few approaches, and linked to the appropriate page. Thanks – GKelly Dec 07 '11 at 15:16