[Pkg-xen-devel] [PATCH 14/16] d/shuffle-binaries: Switch loop from for to while

Elliott Mitchell ehem+debian at m5p.com
Mon Jan 4 06:14:02 GMT 2021


A for loop forces the shell to allocate memory for every filename the
script runs on.  While not yet a concern, in a theoretical future where
hundreds or thousands of files are being worked with, this would become
a concern.  Additionally using "$t"/usr/*bin is compatible with shells
besides Bash, and will work in a future where /usr/xbin exists.

Signed-off-by: Elliott Mitchell <ehem+debian at m5p.com>
---
 debian/shuffle-binaries | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/shuffle-binaries b/debian/shuffle-binaries
index d7a832bbe0..d41d4e11aa 100755
--- a/debian/shuffle-binaries
+++ b/debian/shuffle-binaries
@@ -22,7 +22,7 @@ cd=/usr/lib/xen-common/bin
 
 mkdir -p "$t/$vd"
 
-for binary in `find $t/usr/{bin,sbin} -type f`; do
+find "$t"/usr/*bin -type f | while read binary; do
 	# filter for executables (ignore scripts)
 	file "$binary" | grep -q -eELF.\\+version.\\+interpreter || continue
 
-- 


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg at m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445






More information about the Pkg-xen-devel mailing list