Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
85 Views

Fix for broken script compilervars.sh with zsh on MacOS after latest compiler upgrade

The most recent version of the shell script compilervars.sh added a section  to

remove duplicate paths.     Its fine for bash, but breaks zsh (whis no default in MacOS.

"echo $(!arg) "  is incorrect  syntax in  the zshell scripting.

 I found the fix below ,   It might be useful for anyone using zhell on macos.

I not sure how to report this to the product team.

(the uncorrected script destroys $PATH  for command line users))

 

Broken script

------------------function remove_duplicate_paths----------------------------

remove_duplicate_paths() {
local arg=$1

if [ "${INTEL_HOST_PLATFORM}" = "Darwin" ]; then
local arr=(`echo ${!arg} | sed 's/:/\'$'\n/g'`)
else
local arr=(`echo ${!arg} | sed 's/:/\n/g'`)
fi

fixed script below


# ------------------function remove_duplicate_paths----------------------------
remove_duplicate_paths() {
local arg=$1
eval "value=\"\${$arg}\""
if [ "${INTEL_HOST_PLATFORM}" = "Darwin" ]; then
local arr=(`echo ${value} | sed 's/:/\'$'\n/g'`)
else
local arr=(`echo ${!arg} | sed 's/:/\n/g'`)
fi

Labels (1)
0 Kudos
1 Reply
Highlighted
Moderator
67 Views

we know about this one.  We have, to date, not supported zsh.  Given that Apple is forcing us to zsh we're adding full POSIX support for zsh and ksh in a future update.

Simplest workaround is:

% bash -c 'source /opt/intel/bin/compilervars.sh intel64 ; exec zsh'

Which will end up with a new zsh instance, so if you exit from the new instance you will lose the env vars.

0 Kudos