Too ugly for living (?) but portable: writehex () { printf %b `printf \\\\%03o "$@"` ; }
readonebyteinhexzero() { read dummy hex << EOF $(dd bs=1 count=1 2> /dev/null | od -t x1) EOF if test x"$hex" = "x" ; then return 77; fi if test $(expr length "$hex") = "1" ; then hex="0$hex"; fi if test x$hex = "x00"; then printf "\n"; else printf " 0x%s" $hex; fi return 0; } (while readonebyteinhexzero; do true; done;) | while IFS=: read path ; do writehex $path; done; On Sat, Aug 24, 2013 at 11:38 AM, Raphael Hertzog <hert...@debian.org> wrote: > On Fri, 23 Aug 2013, Bastien ROUCARIES wrote: >> Find -print0 >> >> And replacing read by read -r -d $'\0' is safer but I do not know if it is >> portable. >> >> Or xargs but we need to fork for each file and we get the portability >> problem of find print0. >> >> What do you prefer ? > > find -print0 is fine, dpkg-deb already uses it. > read -d is likely a problem however (I believe it's bash specific). > > I don't think that I have any good answer if we want to support newlines > in filenames. But it's probably not an important use case as dpkg itself > doesn't cope very well with it. dpkg-deb builds it fine and it installs > fine but when you do "dpkg -L" you get this back (with a single > "hello\nworld" file): > $ dpkg -L foo > /. > /hello > /world > > (This is because the /var/lib/dpkg/info/*.list files are line based) > > So I would go ahead ignoring this specific problem. Otherwise you could > write that specific part in perl but it would be a regression to reintroduce > perl in dpkg itself. > > Cheers, > -- > Raphaël Hertzog ◈ Debian Developer > > Discover the Debian Administrator's Handbook: > → http://debian-handbook.info/get/ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org