usr bin env bash while getopts opt do case opt in echo -a OPTARG PARAM

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
while getopts "a:v:h" opt;
do
case $opt in
a)
echo "-a $OPTARG";
PARAM_A="PARAM_A";
;;
v)
echo "-$opt $OPTARG";
PARAM_V="PARAM_V";
;;
h)
echo "Help";
exit 0;
;;
*)
echo "Error: unknown param!";
exit 1;
;;
esac
done
test -z "$PARAM_A" && test -z "$PARAM_V" && {
echo "You should not pass!";
exit 2;
}
exit 0;