I'm trying to write a bash script that will check command line switchess and use the very next argument for the switches argument.
Example:
sh myprogram.sh -s switchArg -p programArg start
Within my script I'm trying to loop it this way:
if [ "$#" -gt 2 ]
then
{
    i=1
    for arg in "$@"
    do
      if [ "$arg" == "-s" ] || [ "$arg" == "-S" ]
      then
      {
          i=$((i++))
          myArg=$i  # This then gets used later in my script
          continue
      }
      elif [ "$arg" == "-p" ] || [ "$arg" == "-P" ]
      then
      {
         i=$((i++))
         myArg2=$i  # This then gets used later in my script
         continue
      }
      else
      {
         echo "illegal option: $arg"
      }
   done
   do stuff
}
fi
How can I detect a switch and use the very next arg for the argument of the switch regardless of the amount of switches?
 
    