Skip to content

Commit

Permalink
implement purify in pure bash for speed
Browse files Browse the repository at this point in the history
  • Loading branch information
ap committed Sep 27, 2014
1 parent 38bcb13 commit daa2c94
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2422,15 +2422,21 @@ __perlbrew_reinit() {
__perlbrew_set_path
}
__perlbrew_set_path () {
MANPATH_WITHOUT_PERLBREW=`perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_HOME}) < 0 } grep { index($_, $ENV{PERLBREW_ROOT}) < 0 } split/:/,qx(manpath 2> /dev/null);'`
export MANPATH=$PERLBREW_MANPATH${PERLBREW_MANPATH:+:}$MANPATH_WITHOUT_PERLBREW
unset MANPATH_WITHOUT_PERLBREW
PATH_WITHOUT_PERLBREW=$(eval $perlbrew_command display-pristine-path)
export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$PATH_WITHOUT_PERLBREW
unset PATH_WITHOUT_PERLBREW
__perlbrew_purify () {
local path patharray outsep
IFS=: read -ra patharray <<< "$1"
for path in "${patharray[@]}" ; do
case "$path" in
*"$PERLBREW_HOME"*) ;;
*"$PERLBREW_ROOT"*) ;;
*) printf '%s' "$outsep$path" ; outsep=: ;;
esac
done
}
__perlbrew_set_path () {
export MANPATH=$PERLBREW_MANPATH${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath)")
export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify "$PATH")
hash -r
}
Expand Down

0 comments on commit daa2c94

Please sign in to comment.