summaryrefslogtreecommitdiff
path: root/tools/list_protos_in_cap.sh
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-03-22 15:10:34 +0100
committerAnders Broman <a.broman58@gmail.com>2015-03-25 07:09:41 +0000
commit1ba4191c70784698a2fac085c508343d85c56486 (patch)
tree058ef568a98507559f034a174c58e10e22be7741 /tools/list_protos_in_cap.sh
parent68698db8ccec8733929752c4b13da71dcad6213e (diff)
downloadwireshark-1ba4191c70784698a2fac085c508343d85c56486.tar.gz
indexcap.py: fix tmpdir handling, python 3 compat
Add Python 3 compatibility to indexcap.py and only create a tmpdir for actions that need it. Only remove tmpdir for the compare action and try to remove the temp dir even if an exception occurs. In list_protos_in_cap.sh, rename BIN_DIR to WS_BIN_PATH (matching test/config.sh) and allow it to be overridden from the environment. Tested with Python 2.6.6, 2.7.9, 3.2.6, 3.4.3 as follows (with tshark built using cmake and '-b /tmp/wsbuild/run'): tools/indexcap.py out pop-ssl.pcapng; tools/indexcap.py out pop-ssl.pcapng --list-all-proto; tools/indexcap.py out pop-ssl.pcapng --list-all-files; tools/indexcap.py out pop-ssl.pcapng --list-all-proto-files=ssl; rm out; Python 2.5.6 does not work (there is no multiprocessing module). The dict output in Python 3.4.3 is different (has the hash function changed?) Change-Id: I592d8c4458a20d5088d815c6dd1cf90c9d3df9d3 Reviewed-on: https://code.wireshark.org/review/7792 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools/list_protos_in_cap.sh')
-rwxr-xr-xtools/list_protos_in_cap.sh20
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/list_protos_in_cap.sh b/tools/list_protos_in_cap.sh
index 37348adedb..f2e24822da 100755
--- a/tools/list_protos_in_cap.sh
+++ b/tools/list_protos_in_cap.sh
@@ -32,13 +32,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Directory containing binaries. Default current directory.
-BIN_DIR=.
+WS_BIN_PATH=${WS_BIN_PATH:-.}
# Tweak the following to your liking. Editcap must support "-E".
-TSHARK="$BIN_DIR/tshark"
-CAPINFOS="$BIN_DIR/capinfos"
+TSHARK="$WS_BIN_PATH/tshark"
+CAPINFOS="$WS_BIN_PATH/capinfos"
-if [ "$BIN_DIR" = "." ]; then
+if [ "$WS_BIN_PATH" = "." ]; then
export WIRESHARK_RUN_FROM_BUILD_DIRECTORY=
fi
@@ -67,7 +67,7 @@ do
"$CAPINFOS" "$CF" > /dev/null 2>&1 && FOUND=1
if [ $FOUND -eq 1 ]
then
- break
+ break
fi
done
@@ -82,7 +82,7 @@ fi
for CF in "$@" ; do
if [ "$OSTYPE" == "cygwin" ] ; then
- CF=`cygpath --windows "$CF"`
+ CF=`cygpath --windows "$CF"`
fi
if [ ! -f "$CF" ] ; then
@@ -93,15 +93,15 @@ for CF in "$@" ; do
"$CAPINFOS" "$CF" > /dev/null
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
- echo "Not a valid capture file (or some other problem)" 1>&2
- continue
+ echo "Not a valid capture file (or some other problem)" 1>&2
+ continue
fi
printf "%s: " "$CF"
# Extract the protocol names.
- $TSHARK -T fields -eframe.protocols -nr "$CF" 2>/dev/null | tr ':\r' '\n' \
- | sort -u | tr '\n\r' ' '
+ $TSHARK -T fields -eframe.protocols -nr "$CF" 2>/dev/null | \
+ tr ':\r' '\n' | sort -u | tr '\n\r' ' '
printf "\n"
done