[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: portability of 'printf' command

From: Eric Blake
Subject: Re: portability of 'printf' command
Date: Tue, 06 Apr 2010 07:01:21 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b1 Thunderbird/3.0.4

On 04/05/2010 05:42 PM, Dr. David Kirkby wrote:
>>> Is someone aware of a platform that does not have a /usr/bin/printf or
>>> /bin/printf program?
>> Given that Solaris 8 is about as far back as gnulib currently supports,
>> I think we are at the point where the known lack of printf(1) in older
>> Solaris is no longer worth worrying about.  And, given that we document
>> that awk is safe to use in Makefiles, in spite of its portability
>> problems, I don't think it is too much of a stretch to support careful
>> use of printf in portable scripting (the Autoconf manual already does a
>> good job at documenting considerations to be careful of before using
>> printf).  So, does this patch seem reasonable?
> There are quite a few pre Solaris 8 systems around - since Solaris tends
> to be used for mission-critical applications, it is often not wise to
> update them just because a new release has extra features.

You missed my point.  Solaris 8 _has_ printf(1) (even though it is not a
shell built-in of /bin/sh, and it can dump core on super-long input), so
the request to add printf as a portable tool does _not_ exclude Solaris
8.  The question at hand is whether it is enough to know how to portably
use printf while avoiding core dumps of less-than-stellar
implementations, and blindly assume that printf(1) exists, or whether we
still need to cater to even older systems (SunOS 4, for example) that
have no printf(1) at all.

And the reason that I would _like_ to have printf(1) added to the list
of portable tools is because of the number of non-portable shell scripts
that are currently using 'echo -n', which is doomed to failure in some
shells, instead of printf because printf was not listed in the permitted

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]