2

I meet a problem that when I run clearcase command:

ct find . -branch 'brtype(my_branch)' -exec "echo %CLEARCASE_XPN%"`

%CLEARCASE_XPN% not parsed as a variable and the output is:

%CLEARCASE_XPN%
%CLEARCASE_XPN%
%CLEARCASE_XPN%
...

But I'm sure CLEARCASE_XPN is the variable denotes the whole path of the found file.
Can anybody help? OS is linux, shell is tcsh, thanks!

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Kery
  • 513
  • 8
  • 22

1 Answers1

1

Use:

ct find . -branch 'brtype(my_branch)' -exec 'echo $CLEARCASE_XPN'

%CLEARCASE_XPN% is a windows syntax.

$CLEARCASE_XPN is the unix syntax, that you can use in your Linux tcsh session.

See "cleartool find" and "Additional examples of the cleartool find command" for many examples using the unix syntax.


Note also the use of simple quotes around the exec directive: -exec 'echo $CLEARCASE_XPN'.
That will prevent the shell itself to interpret immediately the $CLEARCASE_XPN variable (which is unknow for the tcsh session) and will allow the cleartool find to pass the right value to the exec directive, replacing $CLEARCASE_XPN with the extended pathname.

See "String quoting (single quote) vs. Weak Quoting (double quote)":

  • Strong quoting prevents characters from having special meanings, so if you put a character inside single quotes, what you see is what you get.
    Therefore, if you are not sure if a character is a special character or not, use strong quotation marks.

  • Weak quotation marks treat most characters as plain characters, but allow certain characters (or rather meta-characters) to have a special meaning. As the earlier example illustrates, the backslash within double quotation marks is a special meta-character.
    It indicates the next character is not, so it can be used before a backslash and before a double quotation mark, escaping the special meaning.
    There are two other meta-characters that are allowed inside double quotation marks: the dollar sign, and the back quote.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have tried this, but it doesn't work. The feedback is: CLEARCASE_XPN: Undefined variable. – Kery Jul 11 '12 at 09:40
  • @Kery Try with simple quotes: `-exec 'echo $CLEARCASE_XPN'` – VonC Jul 11 '12 at 09:49
  • @Kery Excellent. I have edited the answer to reflect the use of single quotes (aka "strong quoting") and to explain it. – VonC Jul 11 '12 at 10:29