brinckmann / montepython_public

Public repository for the Monte Python Code
MIT License
93 stars 77 forks source link

addvar:1: bad substitution after sourcing clik_profile.zsh #287

Closed westinhuang closed 9 months ago

westinhuang commented 2 years ago

I use 2020 Macbook Pro Monterey 12.4 to install Planck likelihood in zsh shell. ./waf configure --install_all_deps" and "./waf install" in the terminal are finsihed. However, after follow these

$ cp bin/clik_profile.sh bin/clik_profile.zsh
$ sed -i 's/addvar PATH /PATH=$PATH:/g' bin/clik_profile.zsh
$ sed -i 's/addvar PYTHONPATH /PYTHONPATH=$PYTHONPATH:/g' bin/clik_profile.zsh
$ sed -i 's/addvar LD_LIBRARY_PATH /LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/g' bin/clik_profile.zsh

Then type source bin/clik_profile.zsh, I get the following error: addvar:1: bad substitution Some resources said that it is from

function addvar () {
local tmp="${!1}" ;
tmp="${tmp//:${2}:/:}" ; tmp="${tmp/#${2}:/}" ; tmp="${tmp/%:${2}/}" ;
export $1="${2}:${tmp}" ;
}
dchooper commented 1 year ago

Hi,

After running the above commands, you shouldn't have any calls to the addvar function in the resulting .zsh file. The "sed" commands are substituting the addvar for the full path. You can check if your .zsh file still has the addvars, and if so you can manually change that as those commands above should do. Let me know if that works!

Cheers, Deanna