Fix lxc-netstat -- argument processing

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@oracle.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Dwight Engen 2012-10-31 17:08:13 +01:00 committed by Daniel Lezcano
parent a3812bf0c7
commit a24c5a40dc

View File

@ -67,19 +67,8 @@ get_parent_cgroup()
done done
} }
shortoptions='hn:'
longoptions='help,name:,exec'
getopt=$(getopt -o $shortoptions --longoptions $longoptions -- "$@")
if [ $? != 0 ]; then
usage
exit 1;
fi
exec="" exec=""
eval set -- "$getopt"
while true; do while true; do
case $1 in case $1 in
-h|--help) -h|--help)
@ -91,7 +80,7 @@ while true; do
--) --)
shift; break;; shift; break;;
*) *)
break; break;;
esac esac
done done