summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMark Phillips <mark.phil@samsung.com>2016-10-20 18:50:26 +0100
committerGuy Harris <guy@alum.mit.edu>2017-02-15 20:58:43 +0000
commit64f83641ad1ddd8969b08ccb64975daa582427f5 (patch)
treeb698af9c643fa0c79df879e2467ed4a023f85372 /tools
parent0f5948015d96fdb198fb4b26a810404b1225462c (diff)
downloadwireshark-64f83641ad1ddd8969b08ccb64975daa582427f5.tar.gz
Cleanup runlex.sh to use builtin POSIX functions instead of sed
Bug: 13412 Change-Id: If43b30a33dcc4f23ba2bcb3cce3d0feea0d9fe40 Reviewed-on: https://code.wireshark.org/review/20120 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/runlex.sh21
1 files changed, 5 insertions, 16 deletions
diff --git a/tools/runlex.sh b/tools/runlex.sh
index 48a27b6142..cc77d31543 100755
--- a/tools/runlex.sh
+++ b/tools/runlex.sh
@@ -5,7 +5,6 @@
# Script to run Flex.
# First argument is the (quoted) name of the command; if it's null, that
# means that Flex wasn't found, so we report an error and quit.
-# Second arg is the sed executable
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org>
@@ -29,9 +28,9 @@
#
# Get the name of the command to run, and then shift to get the arguments.
#
-if [ $# -lt 2 ]
+if [ $# -lt 1 ]
then
- echo "Usage: runlex <Flex command to run> <path to sed> [ arguments ]" 1>&2
+ echo "Usage: runlex <Flex command to run> [ arguments ]" 1>&2
exit 1
fi
@@ -58,17 +57,6 @@ then
exit 1
fi
-SED="$1"
-shift
-#
-# Check whether we have sed.
-#
-if [ -z "${SED}" ]
-then
- echo "Sed was not found" 1>&2
- exit 1
-fi
-
#
# Process the flags. We don't use getopt because we don't want to
# embed complete knowledge of what options are supported by Flex.
@@ -83,7 +71,8 @@ do
#
# Set the output file name.
#
- outfile=`echo "$1" | ${SED} 's/-o\(.*\)/\1/'`
+ # remove the -o prefix using POSIX sh parameter expansion
+ outfile="${1#-o}"
;;
-*)
@@ -109,7 +98,7 @@ done
# is .../foo.c, the header file will be .../foo_lex.h.
#
#echo "Getting header file name"
-header_file=`dirname "$outfile"`/`basename "$outfile" .c`_lex.h
+header_file="${outfile%.c}_lex.h"
#
# OK, run Flex.