dotfiles/bin/parse_addpath

25 lines
532 B
Bash
Executable File

#!/usr/bin/env bash
# read addpath file and return each path
file="$HOME/.addpath"
paths=
getpaths() {
while read line; do
# If the path doesn't begin with / then assume it is relative to $HOME
# Who cares if this is bashism
if [[ ! "$line" == /* ]]; then
line=$HOME/$line
fi
echo -n "$line "
done < "$1"
}
paths="$(getpaths $file)"
if [ -f "${file}_local" ]; then
paths="$(getpaths ${file}_local) $paths"
fi
paths="$HOME/bin $HOME/local/bin $paths"
echo "$paths"