简体   繁体   中英

Eclipse program arguments, pass literal variable names

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM