[illumos-Developer] webrev: printf

Garrett D'Amore garrett at nexenta.com
Thu Oct 14 08:55:42 PDT 2010


The new webrev with this change is here:

http://cr.illumos.org/view/kx0342it/

	- Garrett

On Thu, 2010-10-14 at 08:41 -0700, Garrett D'Amore wrote:
> So I did find one statement, which caused to add a few lines of code:
> 
> Standard utilities that do not accept options,
> 	 * but that do accept operands, shall recognize "--" as a
> 	 * first argument to be discarded.
> 
> 
> So I added this to the program:
> 
> 	/*
> 	 * POSIX says: Standard utilities that do not accept options,
> 	 * but that do accept operands, shall recognize "--" as a
> 	 * first argument to be discarded.
> 	 */
> 	if (strcmp(argv[0], "--") == 0) {
> 		argc--;
> 		argv++;
> 	}
> 
> (Argv[0] here is after we've skipped past argv[0] for the program name
> itself.)
> 
> Apart from that particular test, I can't imagine what kind of tests
> you'd have for - arguments.
> 
> My testing shows that legacy printf also behaves the same way... it will
> discard -- but not -<letter>.
> 
> 	- Garrett
> 
> On Thu, 2010-10-14 at 17:37 +0200, Nicholas George wrote:
> > On 14 October 2010 17:03, Guido Berhoerster
> > <guido+illumos.org at berhoerster.name> wrote:
> > > * Garrett D'Amore <garrett at nexenta.com> [2010-10-14 04:08]:
> > >> So I finally got tired of waiting for someone else to do a printf
> > >> replacement-- I had thought this would be a trivial thing to do via
> > >> ksh93.  It wasn't, and I wound up taking a different route after first
> > 
> > >> trying to use ksh93.   There are details here:
> > >>
> > >> http://gdamore.blogspot.com/2010/10/new-implementation-of-printf.html
> > >>
> > >
> > > What compatibility problems is this supposed to address or better
> > > what is the overall strategy regarding shell and shell-utilities
> > > compatibility here?
> > >
> > > Is this really necessary when both /sbin/sh and /usr/bin/ksh in
> > > current OpenSolaris/Illumos are already fundamentally incopatible
> > > to Solaris 10 and earlier?
> > >
> > > Any /sbin/sh script calling printf without absolute path will get
> > > the ksh93 builtin anyway (and is likely break in other ways if it
> > > expects to get the SVR4 shell).
> > >
> > > BTW, this behavior is not ksh93-specific, the builtins of bash
> > > and even ancient ash barf on such broken usage of printf.
> > 
> > I have to second that. I don't want to join the argument fray of bash
> > vs Freebsd vs ksh93 but my opinion is that Garrett's bashing of David
> > Korn is unjustified.
> > The issue whether /bin/printf must print options it does not support
> > on stdout or barf with an error has been the topic of discussions and
> > a interpretation request. The binding conclusion is that printf
> > followed by a - and character, while used sparsely in the past, is NOT
> > a valid usage, except the - and the character compose a valid option
> > for the implementation.
> > According to these findings VSC has a whopping 9 new tests to verify
> > that printf does reject unsupported options and vendors, starting with
> > IBM's AIX, have acted and modified their /bin/printf implementation to
> > match the standard.
> > 
> > In my humble opinion, bash/ksh93/ash or not, /bin/printf in Illumos
> > should follow the standard and not introduce a behaviour which is in
> > violation of that standard.
> > 
> > Nicholas
> 
> 
> _______________________________________________
> Developer mailing list
> Developer at lists.illumos.org
> http://lists.illumos.org/m/listinfo/developer




More information about the Developer mailing list