#!/usr/bin/env bash

# set argument list, just as if the script were called with these arguments
set -- -d /root/ -n "dhoni" -n "kohli"

# Initialize your array to start out empty
empnames=( )

while getopts "d:n:" arg; do
   case "$arg" in
      d) path="$OPTARG" ;;
      n) empnames+=( "$OPTARG" ) ;;
   esac
done

for arg in "${empnames[@]}"; do
  echo "$arg"
done
