[lxc-devel] [PATCH 1/1] Cleanup partial container if -h was passed to template

Serge Hallyn serge.hallyn at canonical.com
Fri Aug 17 02:12:48 UTC 2012


If user calls 'lxc-create -t ubuntu -- -h' (as opposed to
'lxc-create -t ubuntu -h') then the ubuntu template will print its
help then exit 0.  Then lxc-create does not cleanup.  So detect this
in lxc-create.
---
 src/lxc/lxc-create.in |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
index 39d6f54..cca4157 100644
--- a/src/lxc/lxc-create.in
+++ b/src/lxc/lxc-create.in
@@ -136,6 +136,18 @@ while true; do
         esac
 done
 
+# If -h or --help was passed into the container, we'll want to cleanup
+# afterward
+wantedhelp=0
+for var in "$@"
+do
+if [ "$var" = "-h" -o "$var" = "--help" ]; then
+    help
+    exit 1
+fi
+done
+
+
 if [ -z "$lxc_path" ]; then
     echo "$(basename $0): no configuration path defined" >&2
     exit 1
-- 
1.7.9.5





More information about the lxc-devel mailing list