From cf068be2d883a87cb68cb7159cfaaf627f67acb3 Mon Sep 17 00:00:00 2001 From: Marco Leogrande Date: Mon, 27 Aug 2012 22:19:51 -0700 Subject: [PATCH] Fix grep pattern when searching for listening sockets The current grep pattern matches also port numbers that match only partially the given $PORT number; e.g., if $PORT is 6080, 60800 will match as well. While TCP listening sockets in the 60000-65535 range are rare, they need to be handled as well. The problem is also present if the user selects a shorter PORT value with the --listen command line argument. By adding a space, the pattern is fixed. --- utils/launch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/launch.sh b/utils/launch.sh index 8afd6e41..26a35320 100755 --- a/utils/launch.sh +++ b/utils/launch.sh @@ -60,7 +60,7 @@ done which netstat >/dev/null 2>&1 \ || die "Must have netstat installed" -netstat -ltn | grep -qs "${PORT}.*LISTEN" \ +netstat -ltn | grep -qs "${PORT} .*LISTEN" \ && die "Port ${PORT} in use. Try --listen PORT" trap "cleanup" TERM QUIT INT EXIT