Package: dash
Version: 0.5.8-2.4
Severity: normal

Dear Maintainer,

I was trying out various examples in article "Rich's sh (POSIX shell)
tricks" and the example in section "Writing bytes to stdout by numeric
value" failed. It was working in Mac OS X /bin/sh.

The error arised when trying to print out a NUL byte.

The following examples will help show what the bug is about:

    $ printf %b '\0074\0101\0076' | hexdump -c
    0000000   <   A   >
    0000003
    $ printf %b '\0074\0001\0076' | hexdump -c
    0000000   < 001   >
    0000003
    $ printf %b '\0074\0000\0076' | hexdump -c
    0000000   <
    0000001
    $ perl -e 'print "<\x{0}>"' | hexdump -c
    0000000   <  \0   >
    0000003

The first two commands work as expected: all three octets are printed on
the standard output, as shown by the output from hexdump.

The third and the last command are expected to yield the same result,
but the one based on printf does not comply and stops processing the
input as soon as it reaches the \0000 string, which is also dropped from
the output.

I scanned through the list of bugs but found none about this specific
issue.

-- System Information:
Debian Release: 9.5
  APT prefers oldstable-updates
  APT policy: (500, 'oldstable-updates'), (500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-7-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8), LANGUAGE=en_US:en 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dash depends on:
ii  debianutils  4.8.1.1
ii  dpkg         1.18.25
ii  libc6        2.24-11+deb9u3

dash recommends no packages.

dash suggests no packages.

-- debconf information:
* dash/sh: true

Reply via email to