bug-bash
[Top][All Lists]
Advanced

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

Re: printf '\x' exit status is 0


From: Stephane Chazelas
Subject: Re: printf '\x' exit status is 0
Date: Wed, 11 Jul 2007 17:57:03 +0100
User-agent: Mutt/1.5.6i

On Tue, Jul 10, 2007 at 09:35:56PM -0400, Chet Ramey wrote:
> Poor Yorick wrote:
> > (on my debian system, bashbug reports for bash 2.05)
> > 
> > printf status is 0 but /usr/bin/printf is 1.  Is this the expected behavior?
> > 
> > address@hidden:~$ bash3
> > address@hidden:~$ bash3 --version
> > GNU bash, version 3.00.16(1)-release (i386-pc-linux-gnu)
> > Copyright (C) 2004 Free Software Foundation, Inc.
> > address@hidden:~$ printf '\x'
> > bash3: printf: missing hex digit for \x
> > address@hidden:~$ echo $?
> > 0
> 
> Bash treats unrecognized backslash escapes as characters to be printed
> and does not consider them an error.  \x without any hex digits doesn't
> have any special meaning, though, since it's probably not what's
> intended, bash prints a warning.
[...]

Note that both AT&T ksh and zsh output a NUL byte and return
success there. pdksh derivatives (pdksh, mksh, posh) output an
error message and return 1. ash derivatives output "\x" and
return success.

The behavior of printf upon \x is /unspecified/ as per POSIX, so
all the behaviors observed are valid. A portable application
shouldn't use printf '\x<whatever>'. The octal representation
(\o, \oo or \ooo) is standard.

-- 
St├ęphane




reply via email to

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