[lxc-devel] [PATCH 2/4] legacy/lxc-ls: use posix shell instead of bash

Stéphane Graber stgraber at ubuntu.com
Tue Dec 25 16:36:12 UTC 2012


On 12/25/2012 05:08 PM, Natanael Copa wrote:
> - 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 at alpinelinux.org>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

Pushed to staging. Thanks.

I also fixed a minor indent problem in that commit (the last esac was
space indented instead of tab indented).

> ---
>  src/lxc/legacy/lxc-ls.in | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/src/lxc/legacy/lxc-ls.in b/src/lxc/legacy/lxc-ls.in
> index f26572d..fbb1385 100644
> --- a/src/lxc/legacy/lxc-ls.in
> +++ b/src/lxc/legacy/lxc-ls.in
> @@ -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
>  }
> @@ -87,7 +84,7 @@ 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"
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20121225/30d6f590/attachment.pgp>


More information about the lxc-devel mailing list