#!/bin/bash
priority=false
it=0
dir=/
while getopts "p:i" option
do
case $option in
i) it=$OPTARG;;
p) priority=true;;
esac
done
if [[ ${@:$OPTIND} != "" ]]
then
dir=${@:$OPTIND}
fi
echo $priority $it $dir
If I execute it I get 2 testDir
for $dir
and 0
for $it
, instead of just testDir
for $dir
and 2
for $it
. How can I get the expected behavior?
./test.sh -pi 2 testDir
true 0 2 testDir