0

I am using this code:

#!/bin/sh
if [ $# -lt 2 ]
then
    echo "wrong syntax"
    echo "ct_cmp.sh <label1> <label2> [<file_extension>]"
else
    if [ $# -eq 2 ]
    then
        cleartool find . -version 'lbtype($1) && \!lbtype($2)' -print
    fi
fi

but get this result:

cleartool:

Error: Invalid query: "lbtype($1) && \!lbtype($2)"
0
4

The single quote will prevent the expansion of the parameters in:

'lbtype($1) && \!lbtype($2)'

It should work with "'lbtype($1) && \!lbtype($2)'".

On a side note, one of my go-to tools when working on shell script is to validate them with shellcheck: https://www.shellcheck.net/ (also available in the standalone executable). Without surprise, it will tell you exactly the same thing about the simple quote.

3
  • 1
    apt-get install chellcheck to install on debian and derivatives. – ctrl-alt-delor Nov 16 '18 at 12:20
  • Do you still need the single quotes? – ctrl-alt-delor Nov 16 '18 at 12:21
  • I tried, but now i get this error message: cleartool: Error: Unrecognized operator: "'lbtype". – parafux Nov 19 '18 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.