implement export (contd)

extract find_envvar() for reusing code