-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathlong_opts.sh
36 lines (32 loc) · 1.11 KB
/
long_opts.sh
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
31
32
33
34
35
36
#!/bin/bash
logo(){
}
intel(){
echo -e "Starting to Gather Intel ..!";
echo -e "passed value $val"
}
while getopts ":h-:" optchar;do
case "${optchar}" in
-)
case "${OPTARG}" in
ia)
val="${!OPTIND}"; OPTIND=$(( $OPTIND + 1))
intel;
;;
*)
if [ "$OPTERR" = 1 ] && [ "${optspec:0:1}" != ":" ]; then
echo "Unknown option --${OPTARG}" >&2
fi
;;
esac;;
h)
echo "usage: $0 [--ia] <value>"
exit 2
;;
*)
if [ "$OPTERR" != 1 ] || [ "${optspec:0:1}" = ":" ]; then
echo "Non-option argument: '-${OPTARG}'";
fi
;;
esac
done