[lxc-devel] [PATCH] lxc-ls,lxc-ps: Improve portability
Ryota Ozaki
ozaki.ryota at gmail.com
Thu May 10 16:12:13 UTC 2012
find -printf option may not be avaiable in some implementations,
e.g., busybox. This patch changes the scripts to use -exec
and -print0 which are probably more portable than -printf.
Signed-off-by: Ryota Ozaki <ozaki.ryota at gmail.com>
---
src/lxc/lxc-ls.in | 2 +-
src/lxc/lxc-ps.in | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in
index 11a3b45..3743ed2 100644
--- a/src/lxc/lxc-ls.in
+++ b/src/lxc/lxc-ls.in
@@ -88,7 +88,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 -exec basename {} \; 2>/dev/null)
fi
if [ -z "$containers" ]; then
diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in
index a9923f0..5711af4 100644
--- a/src/lxc/lxc-ps.in
+++ b/src/lxc/lxc-ps.in
@@ -99,10 +99,11 @@ fi
declare -a container_of_pid
container_field_width=9
-IFS=","
if [ -z "$containers" ]; then
- containers=( $(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d -printf "%f," 2>/dev/null) )
+ IFS="\0"
+ containers=( $(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d -exec basename {} \; -print0 2>/dev/null) )
else
+ IFS=","
containers=( $containers )
fi
--
1.7.9.5
More information about the lxc-devel
mailing list