addToSearchPathOnceWithCustomDelimiter() { local delim="$1" local search="$2" local target="$3" local dirs local exported IFS="$delim" read -a dirs <<< "${!search}" local canonical if canonical=$(readlink -e "$target"); then for dir in ${dirs[@]}; do if [ "z$dir" == "z$canonical" ]; then exported=1; fi done if [ -z $exported ]; then eval "export ${search}=\"${!search}${!search:+$delim}$canonical\"" fi fi } addToSearchPathOnce() { addToSearchPathOnceWithCustomDelimiter ':' "$@" } propagateOnce() { addToSearchPathOnceWithCustomDelimiter ' ' "$@" } if [[ -z "$NIX_QT_PIC" ]]; then export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE${NIX_CFLAGS_COMPILE:+ }-fPIC" export NIX_QT_PIC=1 fi