problem with single quotes in a string and findbug

I'm having trouble manipulating a string that contains single quotes (') in it. I'm writing a ksh script to parse in a few queries from a config file, such as this:

findbug \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class 'isequal' "Development" \)

if i physically call this command it works fine and I get my database results, but I am parsing this string from the config file and storing it in a string variable and then trying to use it and it doesn't work.

For instance I have a variable NewQuery which contains the string.
I do echo $NewQuery and this prints out:
findbug \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class 'isequal' "Development" \)

but if i just do $NewQuery to execute that command it complains:
findbug: Syntax Error: Bad operator 'in'.

Usage: findbug [options] [expr \&\& expr \|\| expr ...]

any idea what i'm doing wrong?

the shell substitutes the command just one time, $NewQuery substitutes the variable once, an then directly calls the programm findbug with the argument
\(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class 'isequal' "Development" \)
without removing \ and '

yes that is what i'm trying to do, run the program findbug with the argument \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class 'isequal' "Development" \)

but the shell will not execute it when i call $NewQuery. It finds the first single quote 'in' and then complains.

but if i type the whole thing out:
findbug \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class 'isequal' "Development" \)

it executes fine. what is the difference?

eval findbug "${NewQuery}"

i knew it was gonna be something so easy. thanks so much!

running # $NewQuery generates the command as I wrote above,

running

# findbug \(\(Project 'in' "Deployment,HDRCI,LHS,LSS,WUCI" '&&' Status 'in' "N" '&&' New_on 'lessthan' "070107" \)\) '&&' \(Class 'isequal' "Development" \)

directly in shell, seems to be the same, but real it runs

findbug ((Project in Deployment,HDRCI,LHS,LSS,WUCI && Status in N && New_on lessthan 070107 )) && (Class isequal Development )

not 100%correct, but I hope its clear what I'm trying to say

when you enter a command the shell parses the command for special characters like $ or many others
' \ " prevent the shell from substituting this special characters, but are removed afterwards

type "man ksh" or "man bash" or wait for someone who speaks better english to explain you this :slight_smile:

ok one more question, how do I store the results in a variable?
I am able to pipe it to a file, but I need to store it as well.

I tried this, but no luck:
results= $(eval $NewQuery)
why doesn't this work?

loose the space after the '=' (assuming ksh/bash)

results=$(eval $NewQuery)   

ok i have another ksh question.

I have a variable QueryString and when I echo it I get:
(( Project in COTS,ROBOINST && Status in N && New_on lessthan 070115 )) && (Class isequal Development )

so when I run this line:
QueryResults=eval findbug $QueryString
the findbug command is called and the correct output is printed out.

but when I run this:
echo "Results = $QueryResults"

I get Results =
and nothing prints out. how do I get the output of the eval findbug $QueryString command into QueryResults? I tried this :
QueryResults=$(eval findbug $QueryString)

but i get an error: syntax error at line 1 : `((' unexpected

thanks for the help

QueryResults=$(eval findbug "${QueryString}")