GKelly
GKelly

Reputation: 3919

How to remove an element named '-c' from ClearCase

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'".

Upvotes: 2

Views: 2770

Answers (2)

hlovdal
hlovdal

Reputation: 28180

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.

Upvotes: 0

VonC
VonC

Reputation: 1323593

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

Upvotes: 1

Related Questions