[cmi] fix generated env.sh file if last env is None (fix #340)