title: accesing functions from external files bash
body: <p>This is really simple but since i m still a newbiw in shell scripting, i  not able to do this. It is simple, i have a menu driven script in which when the user enters his choice i loop in the case function and execute the selected menu. Uptil now i was writing the entire code in the same script. Now i am putting the code in each menu option in a external script and accessing the code from there. So it is something like this,</p>
  
  <pre><code>#!/bin/bash
  . course_func
  file=names.dat
  [ ! -f $file ] &amp;&amp; &gt; $file
  while true
  do
  clear
  echo ------------------------------------------
  echo 1. Create a record
  echo 2. View Records
  echo 3. Search for records
  echo 4. Delete records that match a pattern
  echo ------------------------------------------
  echo "Please enter your choice or enter (q) to quit: \c ";read choice
  case $choice in
      1)
      create()
      echo Enter to continue; read junk
      ;;
          *)
      clear
      echo Wat nonsense enter properly
      echo Enter to continue: ;read crap
      ;;
  esac
  done
  </code></pre>
  
  <p>Then i created another external script where I wrote the create() function</p>
  
  <p>Code is in the link,</p>
  
  <pre><code>create()
  {
    while true
    do
          echo Please enter the name: ;read name
          echo Please enter your surname: ;read surname
          echo Please enter the address: ;read add
          echo Please enter the cell no.: ;read cell
          if yesno Do you really wish to save the following data to file
          then
          echo $name:$surname:$add:$cell &gt;&gt; $file
          clear
          echo The record has been inserted :D
          else 
          echo The record was not save
          fi
          if yesno Do you wish to enter another record
          then
          :
          else
          xit
          fi
    done
  }
  
  addRecord()
  {
  
  }
  
  search()
  {
  
  }
  
  delRecord()
  {
  
  }
  </code></pre>
  
  <p>But i am getting an error,</p>
  
  <pre><code>course_func: line 31: syntax error near unexpected token `}'
  course_func: line 31: `}'
  menu_driven: line 18: syntax error near unexpected token `echo'
  menu_driven: line 18: ` echo Enter to continue; read junk'
  </code></pre>
  
  <p>Line 31 is where I am ending the addRecord function, which is empty function, for the remaining cases. Can we not have a empty function in bash?</p>