It seems the parameter for the delimiter for the read built-in behaves
differently for the NULL case, and it is a very useful case. I found this
after a difficult to track down bug appeared in some of  my code, so I
thought I would pass it on to you.

If it is expected behavior I didn't see it in the documents. Most other
options seem to follow the getopts model and allow for no space for
parameter arguments.

It seems to work for the read built-in yet not for NULL read -d''.

E.g.
$> touch file_{1..40..3}.txt
$> while IFS= read -r -d'.' a; do echo "got $a"; done < <(find . -type f
-print0)
 *                      has the same results as *
$> while IFS= read -r -d '.' a; do echo "got $a"; done < <(find . -type f
-print0)
got
got /file_40
got txt
got /file_37
...
got txt
got /file_1

Yet if we look for the null byte:
$> while IFS= read -r -d'' a; do echo "got $a"; done < <(find . -type f
-print0)
 *                      returns nothing *
$> while IFS= read -r -d '' a; do echo "got $a"; done < <(find . -type f
-print0)
                       *returns the expected results*
got ./file_40.txt
got ./file_37.txt
got ./file_34.txt
...
got ./file_16.txt

Reply via email to