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

writing the opam activation env without relative paths in build_coq_projects.sh #99

Open
brando90 opened this issue Feb 22, 2023 · 2 comments

Comments

@brando90
Copy link

brando90 commented Feb 22, 2023

You should do this:

    # - Adds to the make file for the current project the command to set the opam switch, eval is fine in bash, no further questions needed.
    echo 'eval \"$(opam env --set-switch --switch=$SWITCH)\"' >> coq-projects/$project/make.sh

the one with single quotes evaluated $(...) and thus make the main.sh depedent on the machine and breaks in clusters with multiple servers.


To write the literal string echo "eval "$(opam env --set-switch --switch=$SWITCH)"" without executing the $(opam env --set-switch --switch=$SWITCH) command substitution, you can use single quotes instead of double quotes.

In Bash, single quotes preserve the literal value of all characters within the quotes, so variable substitution and command substitution won't occur. Here's the modified code:

echo 'echo "eval \"$(opam env --set-switch --switch=$SWITCH)\""' >> coq-projects/$project/make.sh
By using single quotes instead of double quotes, the $(opam env --set-switch --switch=$SWITCH) 

command substitution will be treated as a literal string and not evaluated.

@brando90
Copy link
Author

works:

#!/usr/bin/env bash
eval \"$(opam env --set-switch --switch=$SWITCH)\"
make 

inside main.sh

@HazardousPeach
Copy link
Contributor

Sure, that seems like an improvement generally. Want to make a pull request with that change?

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

No branches or pull requests

2 participants