#!/bin/bash function in_envpath() { for path in $(sed 's/:/\n/g' <<< $PATH) do if [ $path = $1 ]; then return 0 # 0 = success! fi done return 1 # non-zero = failure } function add_to_envpath() { if in_envpath $1; then return 0 # Success! Path is already IN $PATH fi if [ -d "$1" ]; then PATH="$PATH:$1" fi }