I need to append a directory to PKG_CONFIG_PATH
. Normally, I would use the standard
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:$(pyenv prefix)/lib/pkgconfig
but PKG_CONFIG_PATH
has not been previously set on my system. Therefore, the variable begins with a :
character, which tells it to look in the current directory first. I do not want that. I settled on the following,
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}$(pyenv prefix)/lib/pkgconfig
but that just seems so ugly. Is there a better way? What is the appropriate way to conditionally append the colon if and only if the variable has already been set?
LD_LIBRARY_PATH
, see e.g.: Empty Entry in LD_LIBRARY_PATH May Lead to Security Issues