help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] About printf "%d\n" with no arguments.


From: Chet Ramey
Subject: Re: [Help-bash] About printf "%d\n" with no arguments.
Date: Wed, 17 Jul 2013 08:57:16 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

On 7/16/13 10:04 PM, Peng Yu wrote:
> Hi,
> 
> The following command will print "0". But I think the appropriate
> output should be nothing. As mentioned in the man page "Write  the
> formatted  arguments  to the standard output under the control of the
> format", since there are no arguments, nothing should be printed. Is
> there a way to configure printf to do what I just described? Thanks.
> 
> ~$ printf "%d\n"
> 0

Try a variant of the following:

printf()
{
        case $# in
        0)      return 0 ;;
        *)      builtin printf "$@" ;;
        esac
}

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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