tools: add options validation.

This prevents to call the apps with incongruent options.

Change-Id: I76919a2da141bd277c06e708548c971c19dd7af7
Reviewed-on: https://code.wireshark.org/review/20211
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Dario Lombardo 2017-02-20 16:35:32 +01:00
parent 8e6b5c14fa
commit f22c7139e0
1 changed files with 9 additions and 2 deletions

View File

@ -62,7 +62,7 @@ while getopts ":2a:b:C:lmnpP:rstTYwcevWdG" OPTCHAR ; do
COMMAND_ARGS="-E 0.02"
# We don't care about the output of editcap
COMMAND_ARGS2="/dev/null" ;;
v) VERBOSE="--num-callers=256" ;;
v) VERBOSE="--num-callers=256 -v" ;;
W) COMMAND=wireshark
COMMAND_ARGS=""
VALID=1 ;;
@ -78,6 +78,13 @@ while getopts ":2a:b:C:lmnpP:rstTYwcevWdG" OPTCHAR ; do
done
shift $(($OPTIND - 1))
# Sanitize parameters
if [ "$COMMAND" != "tshark" ] && [[ $COMMAND_ARGS =~ Vx ]]
then
printf "\nYou can't use -T if you're not using tshark\n\n" >&2
exit 1
fi
if [ $# -ge 1 ]
then
PCAP=$1
@ -135,7 +142,7 @@ cmdline="$LIBTOOL valgrind --suppressions=`dirname $0`/vg-suppressions $ADDITION
--tool=$TOOL $CALLGRIND_OUT_FILE $VERBOSE $LEAK_CHECK $REACHABLE $GEN_SUPPRESSIONS $TRACK_ORIGINS \
$COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2"
if [ $VERBOSE ];then
if [ "$VERBOSE" != "" ];then
echo -e "\n$cmdline\n"
fi