Subject: | bashrc __perlbrew_purify function fails on OS X and strips too many PATHs |
Issue 1: On OS X, the read command (in /usr/bin/read) is a generic shell wrapper to convert the command from upper to lowercase then pass it to the shell builtin. However, the wrapper breaks the array assignment of read.
For the __perlbrew_purify function under bash, it doesn't assign the array properly. Under zsh the -A argument is passed by the wrapper to the /bin/sh builtin of read which doesn't have an -A argument.
Fix for 1: simply call the read command as 'builtin read', like so.
$ diff bashrc bashrc-fixed
18c18
< IFS=: read -r${BASH_VERSION+a}${ZSH_VERSION+A} patharray <<< "$1"
---
Show quoted text
> IFS=: builtin read -r${BASH_VERSION+a}${ZSH_VERSION+A} patharray <<< "$1"
Issue 2: If your PATH contains multiple directories that contain PERLBREW_ROOT, the __perlbrew_purify function removes them all.
For example, before perlbrew, my PATH was set to
PATH=${HOME}/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/libexec:/usr/libexec
and when I installed perlbrew with PERLBREW_ROOT as /usr/local, it converted my PATH to
PATH=/usr/local/bin:${HOME}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/libexec
As you can see, it removed all PATH segments containing /usr/local
Fix for #2: Remove the * wildcards around PERLBREW_ROOT when building the new PATH
$ diff bashrc bashrc-fixed
22c22
< (*"$PERLBREW_ROOT"*) ;;
---
Show quoted text> ("${PERLBREW_ROOT}") ;;