On 2023-12-21 13:48, Zack Weinberg wrote:
> and an unsuccessful exit status.  I would guess that on your machine
> the printf built-in and/or standalone printf executable are not
> reporting write errors.

I think it is not reasonable to expect any utility to report any kind
of error on writes to standard output.  This is not normal behaviour
for C programs and, in the case of printf utilities which are not shell
builtins, such behaviour is likely unique to GNU.

Without /dev/full it is difficult to portably trigger write errors,
but NetBSD 9 has /dev/full and its /usr/bin/printf also does not
report such errors.

You can more reliably get errors by redirecting to a pipe and closing
the read end. since in this case the SIGPIPE will not go unnoticed,
(although an ignored SIGPIPE is inherited from the parent process which
may affect the results).  This can be tricky to setup in a shell script
though.

Cheers,
  Nick

Reply via email to