Fix PATH and MANPATH manipulation in .bashrc

This commit is contained in:
Fernando Schauenburg 2019-02-25 23:30:50 +01:00
parent 33eac53475
commit a13a965961

View file

@ -44,40 +44,41 @@ bashrc_customize_paths() {
# Prevent path_helper from messing with the PATH when starting tmux. # Prevent path_helper from messing with the PATH when starting tmux.
# See: https://superuser.com/a/583502 # See: https://superuser.com/a/583502
if [ "$(uname)" == "Darwin" ]; then if [ "$(uname)" == "Darwin" ]; then
export PATH="" PATH=""
source /etc/profile source /etc/profile
fi fi
# Add custom bin dirs to PATH if they exist and are not already in PATH. # Add custom bin dirs to PATH if they exist and are not already in PATH.
while read p while read p; do
do if [ -d "$p" ] && [[ ":$PATH:" != *":$p:"* ]]; then
if [ -d "$p" ] && [[ ":$MANPATH:" != *":$p:"* ]]; then PATH="$p:$PATH"
MANPATH="$p:$MANPATH"
fi
done <<-EOF
$prefix/share/man
$prefix/opt/coreutils/libexec/gnuman
EOF
# If MANPATH is not yet defined, initialize it with the contents of
# `manpath`.
if [ -z ${MANPATH+x} ]; then
export MANPATH=$(manpath)
fi fi
done <<EOS
$prefix/bin
$prefix/opt/man-db/libexec/bin
$prefix/opt/coreutils/libexec/gnubin
$prefix/opt/gnu-sed/libexec/gnubin
$HOME/.local/bin
$HOME/bin
EOS
export PATH
# Prepend custom man directories to MANPATH if they exist, so that we get # Prepend custom man directories to MANPATH if they exist, so that we get
# correct man page entries when multiple versions of a command are # correct man page entries when multiple versions of a command are
# available. # available.
while read p MANPATH=$(MANPATH= manpath)
do while read p; do
if [ -d "$p" ] && [[ ":$PATH:" != *":$p:"* ]]; then if [ -d "$p" ] && [[ ":$MANPATH:" != *":$p:"* ]]; then
PATH="$p:$PATH" MANPATH="$p:$MANPATH"
fi fi
done <<-EOF done <<EOS
$prefix/opt/coreutils/libexec/gnubin $prefix/share/man
$HOME/.local/bin $prefix/opt/man-db/libexec/man
$HOME/bin $prefix/opt/coreutils/libexec/gnuman
EOF $prefix/opt/gnu-sed/libexec/gnuman
$HOME/.local/share/man
EOS
export MANPATH
} }
bashrc_customize_aliases() { bashrc_customize_aliases() {