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

Hans van Kranenburg hans at knorrie.org
Sat Jan 16 20:12:41 GMT 2021


On 7/17/20 8:37 AM, Elliott Mitchell wrote:
> 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.

Again, I suspect that this is just to be able to switch from bash to sh,
and has little to do with a theoretical future and what else.

> 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
>  
> 




More information about the Pkg-xen-devel mailing list