[Shell] Shell script reads the given parameters

myshell.sh 

#!/bin/sh

function ParaAnalyse()
{
if [ -z "$1" ]
then
echo no para to analyse
else
para=$1
local paraType=${para:O:3} 
case $paraType in
-b:|-B:) boardType=${para:3};;
-s:|-S:) BuildType=${para:3};;
-f:|-F:) filter="-f ${para:3} $filter" ;;
-t:|-T:) specCaseTag="${para :3}";;
-e:|-E:) excludeTag="${excludeTag} -e ${para:3}";;
-c:|-C:) IP=${para:3};;
-m:|-M:) macro2add=${para:3};;
-p:|-P:) productType=${para:3};;
-v:|-V:) ftVersion=${para:3};; coy) BUILD_GCOV=1;;
-h|-H)  #help
echo
echo run_eFT.sh [-b :BPQ] [-s:aU/c/cc/build/runj[v:3_O/qcelIJ
echo [-f:”fixtu re :case”j [-t :“tag”J [-p : lf/hl][-h] echo Options:
echo -b: board type, BPQ, default is BPQ. echo -s: “\“\ means just create project\; \“ccV’create and build project; \“run\” just run the cases;”
echo \“all\” for create, build and test, it isthe default value”.
echo -f: used to filter cases, with fixture and case name, all for default.
echo -t: used to filter cases, with tag name,all for default.
echo -p: -p:hl/lf/subl g, default If
echo -v: use -v:3_0 to specify build spa ft 3.0or qceli,default is 2.0, you should also use -v:3_O to run 3.0 te stcase
echo view the help
echo exit 0
;;
*)
esac
fi
}


function ParaLoop()
{
for arg in $@
do
  echo $arg
  ParaAnalyse $arg
done
}


function BuildProject()
{

ParaLoop $@

echo "boardType is" ${boardType}
echo "BuildType is" ${BuildType}
echo "filter is" ${filter}
echo "specCaseTag is" ${specCaseTag}
echo "excludeTag is" ${excludeTag}

}

BuildProject $@

Instructions:

./myshell.sh -b: b_agr -S: s_arg -E: e_arg ……

Guess you like

Origin blog.csdn.net/bandaoyu/article/details/113770557