-
Notifications
You must be signed in to change notification settings - Fork 90
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
Replace amber text interpolation with bash parameter expansion #592
base: staging
Are you sure you want to change the base?
Conversation
Wow! Tested and this works. Thanks! 🙌 |
@lens0021 the tests doesn't work. Can you check what is happening or you need help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests does't work
This comment was marked as resolved.
This comment was marked as resolved.
So I think that the bash generated is not very ok.
This is an example of the bash generated for the This amber code: |
@lens0021 @Mte90 It seems that only the
It suddenly works. |
But still these two tests fail:
I can't investigate this problem further now. Maybe later today or tomorrow I can play around it |
the tests are still failing |
There are some changes on bash 5.2 $ docker run --rm -v $PWD:/tmp bash:5.1.16 bash /tmp/replace_once.sh
Succinctly\
$ docker run --rm -v $PWD:/tmp bash:5.2.0 bash /tmp/replace_once.sh
Succeeded I will try to write a compatible code... |
Now the both versions are supported. $ cargo run -- build src/tests/stdlib/replace_once.ab src/tests/stdlib/replace_once.sh
Compiling amber v0.3.5-alpha (/usr/local/git/amber)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.52s
Running `target/debug/amber build src/tests/stdlib/replace_once.ab src/tests/stdlib/rep
lace_once.sh`
$ docker run --rm -v $PWD:/tmp bash:5.1.16 bash /tmp/src/tests/stdlib/replace_once.sh
Succeeded
$ docker run --rm -v $PWD:/tmp bash:5.2.0 bash /tmp/src/tests/stdlib/replace_once.sh
Succeeded |
|
Co-authored-by: Huw Walters <[email protected]>
Co-authored-by: Huw Walters <[email protected]>
Tests are now all passed. cargo run -- build src/tests/stdlib/text_replace_one.ab
docker run --rm -v $PWD:/tmp bash:5.1.16 bash /tmp/src/tests/stdlib/text_replace_one.sh
docker run --rm -v $PWD:/tmp bash:5.2.0 bash /tmp/src/tests/stdlib/text_replace_one.sh |
src/std/text.ab
Outdated
pub fun replace(source, search, replace) { | ||
return "\$\{source//{search}/{replace}}" | ||
// Here we use commands for assigning values to avoid the side effect of Amber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will explain the side effect by writing a ticker later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've narrowed down the issue. #646
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking a lot better, added a couple more requests.
I've found a simpler solution and updated the PR. Please re review this from the scratch? I tested it works for two versions: cargo run -- build src/tests/stdlib/text_replace_one.ab
docker run --rm -v $PWD:/tmp bash:5.1.16 bash /tmp/src/tests/stdlib/text_replace_one.sh
docker run --rm -v $PWD:/tmp bash:5.2.0 bash
cargo run -- build src/tests/stdlib/text_replace.ab
docker run --rm -v $PWD:/tmp bash:5.1.16 bash /tmp/src/tests/stdlib/text_replace.sh
docker run --rm -v $PWD:/tmp bash:5.2.0 bash /tmp/src/tests/stdlib/text_replace.sh |
nameof
nameof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. Interesting approach to solving the problem!
Fixes #589.