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

String with ! fails #243

Closed
Mte90 opened this issue Jun 26, 2024 · 4 comments
Closed

String with ! fails #243

Mte90 opened this issue Jun 26, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Mte90
Copy link
Member

Mte90 commented Jun 26, 2024

Try this code:

let var = unsafe $echo "\${\!var}"$

Generates that report the \ near the !:

Expected expression
at ./test.ab:1:26


1| let var = unsafe $echo "{\!var}"$

Instead should work and generate a bash code like var = echo "${!var}", this blocks #185

@Mte90 Mte90 added the bug Something isn't working label Jun 26, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Jun 26, 2024
@b1ek
Copy link
Member

b1ek commented Jun 28, 2024

why should this work? i dont remember ! being a valid amber keyword. is your variable named !var?

@Mte90
Copy link
Member Author

Mte90 commented Jun 28, 2024

Because that is a valid Bash code and it is required to let the #185 working.

@Mte90
Copy link
Member Author

Mte90 commented Jun 28, 2024

@Ph0enixKM
Copy link
Member

Ph0enixKM commented Jul 1, 2024

@Mte90 the problem in your code is that you forgot to escape the interpolation syntax {} that works for Text and Command in Amber:

let name = "Derek"
echo "Hello {name}"
// Outputs: Hello Derek
unsafe $echo "Hello {name}"$
// Outputs: Hello Derek

Here is the corrected code:

let var = unsafe $echo "\$\{!var}"$

You have to escape the { symbol as well and there is no need to escape ! symbol in Command literal

@github-project-automation github-project-automation bot moved this from 🆕 New to 🏁 Done in Amber Project Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants