rhai
rhai copied to clipboard
Escape string interpolation
Writing Bash scripts in Rhai is somewhat uncomfortable when it comes to Bash's ${VAR} syntax:
cmake .. ${cmake_args[@]}
ninja
Currently I have to write
let script = `
cmake .. ${"${cmake_args[@]}"}
ninja
`;
Could there be some forms of escaping this syntax, either double dollar sign ($$) similar to writing back-ticks (``), or a more general escape pattern that includes \$ (or more broadly, \`)?
The thing is, anything wrapped in backticks are supposed to be literal, meaning that there are no escapes.
True that it does make embedding ${ ... } inside back-ticks difficult...
You can use double quotes if you don't need interpolation:
let script = "cmake ${cmake_args[@]}\n\
ninja";
But, of course, other than not having interpolation, you have to live with the ugly \n\ at the end of each line...