Builtin command "printf" of ksh93 does not behave as specified
After opening a shell "/bin/sh" (i.e., ksh93) and typing the following command
one gets an error message:
ksh: printf: -e: unknown option usage: printf [option] ...
This violates the specifications given on the "printf" manual page in many respects:
- According to its manual page, the first argument of printf (both /usr/bin/printf and ksh93's
builtin printf) is always a format string. So, the argument "-e" is a format string ans should
be displayed as such. Instead, ksh93's builtin printf tries to interpret this format string as
a command-line option, which is incorrect.
- Quoting the manual page: "/usr/bin/printf is equivalent to ksh93's printf built-in and print -f,
which which allows additional options to be specified." So, ksh93's printf should behave
like /usr/bin/printf, which displays "-e" (without newline) when invoked with argument "-e".
Because the implementation and the manual page differ, one may wonder which one is
incorrect. I think that the implementation is incorrect, because the manual page states
very clearly, at different places and in different ways, what is expected from the implementation.
Note 1: it is likely that, in ksh93 implementation, there is a confusion between "printf" and "print".
The latter accepts options, including an option "-e". It could be that "printf" tries to share
code with "print", including code to parse options, whereas "printf" should not parse any
option since its first argument is directly a format string.
Note 2: This bug also exists in Solaris 11.4, which seems to indicate that it was introduced
during the Sun times.
No data to display