Bash variable expansion that includes single or double quotes

38 Views Asked by At

I have a script that I'm writing to automate running specific tests with a promela model.

The user must supply the promela model and another file with the ltl properties they wish to run against the model.

I read in the file line by line using the following:

while read line; do 
  do_something()
end < $PROPERTIES

do_something() is more complicated, but the main problem I'm having is that eventually I want to invoke the following

spin -run -m100000 -f $line $PROMELAFILE >> $OUTFILE

The final command should look like the following

spin -run -m100000 -f '[] true' file.pml >> out.txt

The final command does work as intended from the command line. The quotes are absolutely necessary for the -f option to work properly.

The issue is the $line variable, when its read from the file, it looks like the following

' [] true '

it can also look like

" [] true "

which are semantically equivalent.

However, I keep getting the following error

unexpected EOF while look for matching `"'
syntax error: unexpected end of file

This error occurs whether its single quotes or double quotes

This makes me think that when $line is expanded, there's something that I don't understand about bash and the use of ' and ".

Any help/understanding that you can provide would be very helpful. Thank you!

0

There are 0 best solutions below