Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape string interpolation #694

Open
hack3ric opened this issue Jan 23, 2023 · 1 comment
Open

Escape string interpolation #694

hack3ric opened this issue Jan 23, 2023 · 1 comment

Comments

@hack3ric
Copy link

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, \`)?

@schungx
Copy link
Collaborator

schungx commented Jan 24, 2023

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants