Search code examples
bashshelleval

How to properly used an `eval` expression into a bash script?


I have the following bash command related to the activation of conda's base enviroment:

eval "$(/home/lucas/miniconda3/bin/conda shell.bash hook)"

When I run it in the shell everything works fine, but when I try to run it inside a script it does nothing.

I have try all kind of things, mainly regarding quotation, but nothing.

Thanks!


Solution

  • After everybody's comments I saw that the problem was that I had to source the script and not execute it.

    Just to clarify the differences:

    https://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it