]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Add -n differentiation to lxc-netstat
authorAndrew Gilbert <andrewg800@gmail.com>
Thu, 27 Jun 2013 13:09:05 +0000 (08:09 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 27 Jun 2013 13:10:53 +0000 (08:10 -0500)
lxc-netstat now only processes an -n argument if it has not previously
received a value for $name from --name or -n. If it _has_ received such
a value, it stops processing arguments and leaves the -n for netstat.
This does not apply to the use of --name after a name has been provided
by --name or -n; the current behaviour continues. The new behaviour
makes
netstat -n <container> -n -a
behave like
netstat -n <container> -a -n
which already will act as though there is '--' between '<container>' and
'-a' (see line 91 of lxc-netstat.in).

Signed-off-by: Andrew Gilbert <andrewg800@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-netstat.in

index 163027b4e21191ca92fd39f020b87e4c56e11c2a..3ed0487a4fc6b95101a4ef25e3d60218fdcd44e6 100644 (file)
@@ -74,7 +74,17 @@ while true; do
     case $1 in
         -h|--help)
             help; exit 1;;
-        -n|--name)
+        -n)
+            # If we already have a value for $name, treat -n as being an
+            # argument for netstat
+            if [ -n "$name" ]
+            then
+                break
+            else
+                name="$2"; shift 2;
+            fi
+            ;;
+        --name)
             name=$2; shift 2;;
        -P|--lxcpath)
             lxc_path="$2"; shift 2;;