From aeb958be832011009226b39e04d61cfb2a6e7da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 12 Nov 2012 16:20:53 -0500 Subject: [PATCH] lxc-ls: Don't exit 1 when no container or help MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lxc-ls is currently exiting with return code 1 when called with --help or when called on a system without containers. This behaviour isn't documented in the manpage and isn't terribly intuitive. It's been the source of quite a few weird failures in scripts running with set -e. As a user calling --help is a voluntary action, lxc-ls should exit 0. Also, as lxc-ls's goal is solely to list containers, showing an error and exiting with return code 1 when there's no container seems counter-intuitive and error-prone. Signed-off-by: Stéphane Graber --- src/lxc/lxc-ls.in | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in index 9293323c9..f26572da2 100644 --- a/src/lxc/lxc-ls.in +++ b/src/lxc/lxc-ls.in @@ -75,7 +75,7 @@ directory=$(readlink -f "$lxc_path") for i in "$@"; do case $i in --help) - help; exit 1;; + help; exit;; --active) get_parent_cgroup; directory="$parent_cgroup"; shift;; --) @@ -90,10 +90,5 @@ if [ ! -z "$directory" ]; then containers=$(find $directory -mindepth 1 -maxdepth 1 -type d -printf "%f\n" 2>/dev/null) fi -if [ -z "$containers" ]; then - echo "$(basename $0): no containers found" >&2 - exit 1 -fi - cd "$directory" ls -d $@ -- $containers