[lxc-devel] [PATCH] Fix lxc-netstat -- argument processing

Dwight Engen dwight.engen at oracle.com
Thu Oct 25 21:25:09 UTC 2012


Commit 21e487f2 introduced the use of getopt, but getopt will fail when
it sees arguments meant for netstat that are not in [short|long]options.
There should not be any ambiguity about arguments with the same letter:
those to the left of the -- are destined for lxc-netstat and those to
the right for the real netstat, which the original code handles by
shifting out all arguments it recognizes before the -- is hit.

Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 src/lxc/lxc-netstat.in |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in
index 367568c..4abe25f 100644
--- a/src/lxc/lxc-netstat.in
+++ b/src/lxc/lxc-netstat.in
@@ -67,19 +67,8 @@ get_parent_cgroup()
 	done
 }
 
-shortoptions='hn:'
-longoptions='help,name:,exec'
-
-getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
-if [ $? != 0 ]; then
-    usage
-    exit 1;
-fi
-
 exec=""
 
-eval set -- "$getopt"
-
 while true; do
 	case $1 in
 		-h|--help)
@@ -91,7 +80,7 @@ while true; do
 		--)
 			shift; break;;
 		*)
-			break;
+			break;;
 	esac
 done
 
-- 
1.7.1





More information about the lxc-devel mailing list