]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
legacy/lxc-ls: use posix shell instead of bash
authorNatanael Copa <ncopa@alpinelinux.org>
Tue, 25 Dec 2012 16:08:54 +0000 (17:08 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 25 Dec 2012 16:34:03 +0000 (17:34 +0100)
- use case .. in instead of comparison with globs
- avoid 'local'

While here, also avoid 'find ... -printf' which is not supported on busybox

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/legacy/lxc-ls.in

index f26572da2e06cb1d66ff6cadfe5ca999669d4cb7..6757f27bf85ce64afe36877b2d62ff1d2fe4d7b0 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 #
 # lxc: linux Container library
@@ -35,8 +35,6 @@ help() {
 
 get_parent_cgroup()
 {
-       local hierarchies hierarchy fields subsystems init_cgroup mountpoint
-
        parent_cgroup=""
 
        # Obtain a list of hierarchies that contain one or more subsystems
@@ -61,11 +59,10 @@ get_parent_cgroup()
 
                # Return the absolute path to the containers' parent cgroup
                # (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
-               if [[ ",$subsystems," == *,ns,* ]]; then
-                       parent_cgroup="${mountpoint}${init_cgroup%/}"
-               else
-                       parent_cgroup="${mountpoint}${init_cgroup%/}/lxc"
-               fi
+               case ",$subsystems," in
+                       *,ns,*) parent_cgroup="${mountpoint}${init_cgroup%/}";;
+                       *) parent_cgroup="${mountpoint}${init_cgroup%/}/lxc";;
+               esac
                break
        done
 }
@@ -82,12 +79,12 @@ for i in "$@"; do
                        shift; break;;
                *)
                        break;;
-        esac
+       esac
 done
 
 containers=""
 if [ ! -z "$directory" ]; then
-       containers=$(find $directory -mindepth 1 -maxdepth 1 -type d -printf "%f\n" 2>/dev/null)
+       containers=$(find $directory -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')
 fi
 
 cd "$directory"