[Top][All Lists]

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

builtin printf ignores straight '\c'

From: Benno Schulenberg
Subject: builtin printf ignores straight '\c'
Date: Tue, 12 Aug 2008 15:53:03 +0200
User-agent: KMail/1.9.9


Bash's printf appears to ignore the \c backslash escape:

$ printf "before \c after \a"
before \c after $
$ type printf
printf is a shell builtin

Of course the Open Group's description of printf
does not specify that \c in the format string should be interpreted, 
but the builtin echo, and the echo and printf from coreutils, do 
interpret it:

$ echo -e "before \c after \a"
before $
$ type echo
echo is a shell builtin

$ /bin/echo -e "before \c after \a"
before $
$ /usr/bin/printf "before \c after \a"
before $

When \c is provided via the %b conversion specifier, it is 

$ printf "before %b after \a" '\c'
before $      

It makes it seem odd that a straight \c isn't.  (Of course, a 
straight \c is less useful than an indirect one, but still.)

$ bash --version
GNU bash, version 3.2.39(1)-release (i686-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.


reply via email to

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