[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#761423: busybox: using find in pipe with dd produce semi-random output



Package: busybox
Version: 1:1.22.0-8
Severity: normal

Dear Maintainer,

probably the problem is in the mainstream but it affect also Debian.

   * What led up to the situation?

I was trying to find a shell way to check if a directory is empty

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

I created a chroot with only busybox and the libs needed (as shown by ldd) to be sure it is using only busybox commands.

 sudo chroot chrootdir /bin/busybox sh

created a shell function:

isempty() { [ "$(find "$1" -name "?*" | dd bs=$((${#1}+3)) count=1 2>/dev/null)" = "$1" ] ; }
mkdir /test && /test/.x
while [ 1 ] ; do if ! isempty /test ; then echo error ; break ; else echo not empty ; fi ; done

run it few times
run 1 to 3 exit immediatly with error
run 4 show a non emtpy then error
run 5 show 9 non empty then error
(nobody removed or added files in /test)

also running manually the command below show different results from time to time

find /test -name "?*" | dd count=1 2>/dev/null

   * What was the outcome of this action?

output truncated randomically, seem by line ending, when is wrong show only the first line.

   * What outcome did you expect instead?

always the same predictable full output of find.


-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.14-1-686-pae (SMP w/4 CPU cores)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages busybox depends on:
ii  libc6  2.19-10

busybox recommends no packages.

busybox suggests no packages.

-- no debconf information


Reply to: