title: bash - passing optional arguments to script - parametername + string_value
body: <p>i use a script that accepts parameter. parameters are optional and may occur in any order.</p>
  
  <pre><code>#!/bin/bash
  # script name: test.sh
  for var in "$@"
  do
      if [ ! -z "$var" ]   &amp;&amp; ([ $var = "--example" ] || [ $var = "-e" ]); then
          echo "example"
      elif [ ! -z "$var" ]   &amp;&amp; ([ $var = "--project" ] || [ $var = "-p" ]); then
          echo "project with string xxxxxxx"
      fi
  done
  </code></pre>
  
  <p>in this simple example, you could call it like follows (some examples):</p>
  
  <pre><code># this will echo example
  ./test.sh --example 
  # this will echo project with string xxxxxxx
  ./test.sh --project
  # this will echo both example and project with string xxxxxxx
  ./test.sh --example --project
  </code></pre>
  
  <p>NOW, what i want to achieve is that i can do something like this (warning, this is pseuco code):</p>
  
  <pre><code>#!/bin/bash
  # script name: test.sh
  for var in "$@"
  do
      if [ ! -z "$var" ]   &amp;&amp; ([ $var = "--example" ] || [ $var = "-e" ]); then
          echo "example"
      elif [ ! -z "$var" ]   &amp;&amp; ([ $var = "--project" ] || [ $var = "-p" ]); then
          echo "project with string $VAR_VALUE"
      fi
  done
  
  
  
  # this will echo example
  ./test.sh --example 
  # this will echo project with string myproject1
  ./test.sh --project="myproject1" 
  # this will echo both example and project with string myproject2
  ./test.sh --example --project="myproject2"
  </code></pre>
  
  <p>can someone help me rewrite it so this will work somehow?</p>