#!/bin/sh add_entry() { local profile="$1" grep -q '^PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/lib/pkgconfig"$' "${profile}" || { cp "${profile}" "${profile}.new" && \ echo >>"${profile}.new" && \ echo 'PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/lib/pkgconfig"' >>"${profile}.new" && \ echo 'export PKG_CONFIG_PATH' >>"${profile}.new" && \ mv "${profile}.new" "${profile}" } } if [ -d "/scratchbox" ] then add_entry ~/.bash_profile else add_entry "/etc/profile.env" fi