title: How to split string into component parts in Linux Bash/Shell
body: <p>I'm writing the second version of my post-receive git hook.</p>
  
  <p>I have a <code>GL_REPO</code> variable which conforms to:</p>
  
  <pre><code>/project.name/vhost-type/versioncodename
  </code></pre>
  
  <p>It may or may not have a trailing and/or preceding slash.</p>
  
  <p>My current code misunderstood the function of the following code, and as a result it clearly duplicates <code>$versioncodename</code> into each variable:</p>
  
  <pre><code># regex out project codename
  PROJECT_NAME=${GL_REPO##*/}
  echo "project codename is: $PROJECT_NAME"
  
  # extract server target vhost-type -fix required
  VHOST_TYPE=${GL_REPO##*/}
  echo "server target is: $VHOST_TYPE"
  
  # get server project - fix required
  PROJECT_CODENAME=${GL_REPO##*/}
  echo "server project is: $PROJECT_CODENAME"
  </code></pre>
  
  <p>What is the correct method for taking these elements one at a time from the back of the string, or guaranteeing that a three part string allocates these variables? </p>
  
  <p>I guess it might be better to split into an array?</p>