I am writing a program which expects command line arguments of the form
-foo ${foo}
However, ${name} is Eclipse’s notation for variables. Passing the above command line argument causes Eclipse to look for an internal variable named foo and inserting that instead of the ${foo} variable specification before running the program.
What is the proper way of escaping ${foo} so Eclipse will pass it literally, rather than trying to expand it?
CodePudding user response:
TL;DR: $\{foo}
The escape character for Eclipse is \; prepending this will cause Eclipse to pass the following character literally.
Of a string resembling a variable specification, only the opening brace needs to be escaped in order to pass the whole thing literally.
Escaping $ and } is not needed but will do no harm – $\{foo}, \$\{foo} and \$\{foo\} will all result in ${foo} being passed to the program.
