#!/bin/bash# set the default valueXDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}"# add a directory if it existsif[[-d/opt/foo/share]];thenXDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS}fi# write our outputechoXDG_DATA_DIRS=$XDG_DATA_DIRS