Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: printf for converting numbers to letters, bug?
- X-seq: zsh-workers 19698
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: printf for converting numbers to letters, bug?
- Date: Sat, 27 Mar 2004 23:53:12 +0000
- In-reply-to: <20040326170042.GA19532@xxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <1040326164256.ZM18660@xxxxxxxxxxxxxxxxxxxxxxx> <20040326170042.GA19532@xxxxxxxxxxx>
On Mar 26, 12:00pm, Clint Adams wrote:
} Subject: Re: (Fwd) printf for converting numbers to letters, bug?
}
} > Looks like "%c" is interpreting the argument as a string and printing
} > the first character thereof. It should work more like %d, shouldn't it?
}
} Not according to POSIX; the argument to %b, %c, or %s is to be
} interpreted as a string.
Just to clarify my earlier comment:
Zsh is (as of 4.2.0) behaving such that, given x='101',
printf "%c" $x
and
print -r $x[1]
produce the same output. That behavior is nearly useless. (It is how
/usr/bin/printf on Linux works, though, so I guess it can be interpreted
as a compatibility issue.)
} If we had octal brace expansion, he could do something like
} printf "%b\n" \\0{101..145}
If %b interprets the string \0101 as an octal number and prints the
corresponding character, why shouldn't %c interpret the string 101 as a
decimal number and print the corresponding character?
I've just been looking at
http://www.opengroup.org/onlinepubs/007904975/utilities/printf.html
I notice that although it mentions %b, there's NO definition of %b on any
of the pages it cross-references:
http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap05.html
http://www.opengroup.org/onlinepubs/007904975/functions/printf.html
Where is %b defined?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author