title: Set local environmental variable within a bash script
body: <p>I'm trying to set an environmental variable that will persist once the script has finished running. It can go away after I end an ssh session.</p>
  
  <p>Sample bash script:</p>
  
  <pre><code># User picks an option
  1) export dogs = cool
  2) export dogs = not_cool
  </code></pre>
  
  <p>Running the script as <code>source script.sh</code> doesn't work since it kicks me out of my shell when ran and also requires the interactive menu so it won't work. Basically I want the user to be able to pick an option to switch between environmental variables in their shell. Is that even possible?</p>
  
  <p>Source:</p>
  
  <pre><code>#!/bin/bash
  set -x
  show_menu(){
      NORMAL=`echo "\033[m"`
      MENU=`echo "\033[36m"` #Blue
      NUMBER=`echo "\033[33m"` #yellow
      FGRED=`echo "\033[41m"`
      RED_TEXT=`echo "\033[31m"`
      ENTER_LINE=`echo "\033[33m"`
      echo -e "${MENU}*********************************************${NORMAL}"
      echo -e "${MENU}**${NUMBER} 1)${MENU} Option 1 ${NORMAL}"
      echo -e "${MENU}**${NUMBER} 2)${MENU} Option 2 ${NORMAL}"
      echo -e "${MENU}*********************************************${NORMAL}"
      echo -e "${ENTER_LINE}Please enter a menu option and enter or ${RED_TEXT}enter to exit. ${NORMAL}"
      read opt
  }
  function option_picked() {
  COLOR='\033[01;31m' # bold red
  RESET='\033[00;00m' # normal white
  MESSAGE=${@:-"${RESET}Error: No message passed"}
  echo -e "${COLOR}${MESSAGE}${RESET}"
  }
  clear
  show_menu
  while [ opt != '' ]
  do
      if [[ $opt = "" ]]; then
          exit;
      else
          case $opt in
              1) clear;
                  option_picked "Option 1";
                  export dogs=cool
                  show_menu;
                  ;;
              2) clear;
                  option_picked "Option 2";
                  export dogs=not_cool
                  show_menu;
                  ;;
              x)exit;
                  ;;
              \n)exit;
                  ;;
              *)clear;
                  option_picked "Pick an option from the menu";
                  show_menu;
                  ;;
          esac
      fi
  done
  </code></pre>