diff --git a/commonsh/00_helper b/commonsh/00_helper new file mode 100755 index 0000000..0cb0339 --- /dev/null +++ b/commonsh/00_helper @@ -0,0 +1,76 @@ +#! /bin/sh + +concat_path () +{ + if [ -z "$1" ] ; then + echo "Please give me a value to concatinate to the variable!" + exit + fi + + local addition + + addition=$1 + + if [ -d "${addition}" ] ; then + if [ -z "${PATH}" ] ; then + PATH=${addition} + else + PATH=${addition}:${PATH} + fi + + export PATH + fi +} + +concat_manpath () +{ + if [ -z "$1" ] ; then + echo "Please give me a value to concatinate to the variable!" + exit + fi + + local addition + + addition=$1 + + if [ -d "${addition}" ] ; then + if [ -z "${MANPATH}" ] ; then + MANPATH=${addition} + else + MANPATH=${addition}:${MANPATH} + fi + + export MANPATH + fi +} + +# we don't have a MANPATH? we can find one. +if [ -z "${MANPATH}" ] ; then + case `uname -s` in + SunOS) + # some solaris systems have manpath + if ( command -v manpath >/dev/null 2>&1 ) ; then + MANPATH=`manpath` + export MANPATH + else + concat_manpath "/usr/share/man" + fi + ;; + OpenBSD) + concat_manpath "/usr/local/man/old" + concat_manpath "/usr/gnu/man/old" + concat_manpath "/usr/contrib/man/old" + concat_manpath "/usr/X11R6/man/old" + concat_manpath "/usr/X11/man/old" + concat_manpath "/usr/gnu/man" + concat_manpath "/usr/contrib/man" + concat_manpath "/usr/X11R6/man" + concat_manpath "/usr/X11/man" + concat_manpath "/usr/share/man" + ;; + Darwin|Linux|FreeBSD) + MANPATH=`manpath` + export MANPATH + ;; + esac +fi diff --git a/commonsh/01_ports b/commonsh/01_ports index d7ca964..1421c4c 100755 --- a/commonsh/01_ports +++ b/commonsh/01_ports @@ -1,28 +1,7 @@ #! /bin/sh -if [ -d /opt/local/man ] ; then - if [ -z "${MANPATH}" ] ; then - MANPATH="/opt/local/man":`manpath` - else - MANPATH="/opt/local/man:${MANPATH}" - fi - export MANPATH -fi +concat_manpath "/opt/local/man" +concat_path "/opt/local/bin" +concat_path "/opt/local/sbin" +concat_path "/opt/local/libexec" -if [ -d /opt/local/bin ] ; then - if [ -z "${PATH}" ] ; then - PATH="/opt/local/bin" - else - PATH="/opt/local/bin:${PATH}" - fi -fi - -if [ -d /opt/local/sbin ] ; then - PATH="/opt/local/sbin:${PATH}" -fi - -if [ -d /opt/local/libexec ] ; then - PATH="/opt/local/libexec:${PATH}" -fi - -export PATH diff --git a/commonsh/02_term b/commonsh/02_term index a38335a..31a6674 100755 --- a/commonsh/02_term +++ b/commonsh/02_term @@ -42,7 +42,7 @@ fix_term () # sorta hacky, but I cannot find a better way to do this :/ fix_terminfo_db () { - if [ `command -v infocmp 2>/dev/null` = "$1/bin/infocmp" ] ; then + if [ -d "$1" ] && [ `command -v infocmp 2>/dev/null` = "$1/bin/infocmp" ] ; then TERMINFO="$1/share/terminfo" export TERMINFO fi diff --git a/commonsh/03_cabal b/commonsh/03_cabal index bdeccc3..4aa013b 100755 --- a/commonsh/03_cabal +++ b/commonsh/03_cabal @@ -1,11 +1,4 @@ #! /bin/sh -if [ -d "${HOME}/.cabal/bin" ] ; then - if [ -z "${PATH}" ] ; then - PATH="${HOME}/.cabal/bin" - else - PATH="${HOME}/.cabal/bin:${PATH}" - fi -fi +concat_path "${HOME}/.cabal/bin" -export PATH diff --git a/commonsh/10_git b/commonsh/10_git index 2bad1c5..37e6128 100755 --- a/commonsh/10_git +++ b/commonsh/10_git @@ -1,24 +1,6 @@ #! /bin/sh -if [ -d /usr/local/git/man ] ; then - if [ -z "${MANPATH}" ] ; then - MANPATH="/usr/local/git/man":`manpath` - else - MANPATH="/usr/local/git/man:${MANPATH}" - fi - export MANPATH -fi +concat_manpath "/usr/local/git/man" +concat_path "/usr/local/git/bin" +concat_path "/usr/local/git/libexec/git-core" -if [ -d /usr/local/git/bin ] ; then - if [ -z "${PATH}" ] ; then - PATH="/usr/local/git/bin" - else - PATH="/usr/local/git/bin:${PATH}" - fi -fi - -if [ -d /usr/local/git/libexec/git-core ] ; then - PATH="/usr/local/git/libexec/git-core:${PATH}" -fi - -export PATH